统计数中二进制表达式中1的个数

#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int count = 0;
    while(n)
    {
        n = n&(n-1);
        count++;

    }
    cout << count << endl;
    return 0;
}
原文地址:https://www.cnblogs.com/zyqBlog/p/5962377.html