/*
编写一个程序,要求接收一个数字,程序会将这个数字以二进制方
式打印,例如:数字10 , 以1010的方式打印出来
*/
func binaryPrintIntNumber(num : Int) {
var remainderArr:[Int] = [] //int数组,存储余数
var quotient:Int = num //表示商的变量,初始值是num
while quotient > 0 { //商的值是0
let remainderNum = quotient % 2 //获取余数的值
remainderArr.insert(remainderNum, at:
要求接收一个数字,程序会将这个数字以二进制方式打印
最新推荐文章于 2020-12-10 07:01:52 发布