题解 | #查找输入整数二进制中1的个数#
查找输入整数二进制中1的个数
http://www.nowcoder.com/practice/1b46eb4cf3fa49b9965ac3c2c1caf5ad
while True:
try:
num = int(input())
a = bin(num) #十转二
a = list(a)
count = 0
for i in a:
if(i == '1'): #找1的个数
count += 1
print(count)
except:
break
华为机试题解(prod.by kedao) 文章被收录于专栏
华为实习机试题解