最简便的求一个正整数二进制中1的个数的方法 int main() { int n = 0; int count = 0; scanf("%d",&n); while (n) { n &= (n-1); count++; } printf("二进制中1的个数为=%d\n",count); }