#include<stdio.h>
int count(int n)
{
int sum = 0;
while(n)
{
n = n&(n-1);
sum++;
}
return sum;
}
int main ()
{
int sum = 0;
int n = 0;
scanf("%d",&n);
sum = count(n);
printf("##### sum = %d\n",sum);
}
整数二进制中1的个数
最新推荐文章于 2024-01-03 16:36:25 发布