代码
#include<stdio.h>
#include<math.h>
int count(int in)
{
int num=0;
while(in>0)
{
num+=in&1;
in = in>>1;
}
return num;
}
int main()
{
int in;
while(scanf("%d", &in) != EOF)
{
printf("%d\n", count(in));
}
}
参考 https://www.nowcoder.com/profile/282085987/codeBookDetail?submissionId=114675403