代码如下↓
- num = int(input(‘请输入数字’))
- j = ‘’
- while num>1:
-
j = j+str(num%2)
-
if num%2==1:
-
num = int((num-1)/2)
-
else:
-
num = int(num/2)
- j = j+str(num%2)
- if num%2==1:
-
num = int((num-1)/2)
- else:
-
num = int(num/2)
- print(j[::-1])
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)