题解 | #查找输入整数二进制中1的个数#
查找输入整数二进制中1的个数
http://www.nowcoder.com/practice/1b46eb4cf3fa49b9965ac3c2c1caf5ad
#include <stdio.h>
#include <string.h>
//多项式分解
// x= an 2^n+...a2 2^2+ a1 2^1+ a0 2^0
// x%2 =a0 x/=2
int main(){
int n;
while(scanf("%d",&n)!=EOF){
int count=0;
while(n!=0){
count += n%2;
n /=2;
}
printf("%d\n",count);
}
return 0;
}