#include <stdio.h>标签:count,二进制,个数,++,int,num,按位,内存,printf From: https://blog.51cto.com/u_15927947/6023612
int main()
{
//统计num补码中有几个1
int num = 0;
int count = 0;
scanf("%d",&num);
int i = 0;
for (i = 0; i < 32; i++)
{
//按位与--都是1才为1
if (1==((num>>i)&1))
{
count++;
}
}
printf("%d\n", count);
return 0;
}