#include<stdio.h>
int main()
{
int num;
int s=0,yus=0,count=0;
printf("请输入一个数字:");
scanf("%d",&num);
for(s=num;s>=1;)
{
yus=s%2;
s=s/2;
if (yus==1)
{
count++;
}
}
printf("%d\n",count);
return 0;
}
时间: 2024-10-08 19:35:30