题解 | 求int型正整数在内存中存储时1的个数
n = int(input()) i = 0 num = [] while n > 0: a = n % 2 num.append(a) n = n // 2 i = i + 1 print(num.count(1))
n = int(input()) i = 0 num = [] while n > 0: a = n % 2 num.append(a) n = n // 2 i = i + 1 print(num.count(1))
相关推荐