/* printf example */
#include <stdio.h>
int count_one(int n){
int count=0;
while(n){
n=n&(n-1);
count++;
}
return count;
}
int main()
{
int a=-1;
printf("%d",count_one(a));
return 0;
}
结果:
标签:count,return,二进制位,个数,int,printf,整形 From: https://www.cnblogs.com/gaoyuangaoyuan/p/17485379.html