#include<stdio.h>
int count_one_bits(unsigned int value)
{
int count=0;
while(value)
{
if((value&1)==1)
count++;
value=value>>1;
}
return count;
}
int main()
{
unsigned int num=0;
scanf("%d",&num);
printf("%d\n",count_one_bits(num));
return 0;
}
写一个函数返回参数二进制中1的个数
最新推荐文章于 2024-05-08 16:32:15 发布