【摘自编程之美】
#include <iostream>
using namespace std;
int findone(unsigned int n)
{
int i;
for(i=0; n>0; n>>=1)
i+=(n&1);
return i;
}
int func(unsigned int n)
{
int count=0;
while(n>0)
{
n&=(n-1);
count++;
}
return count;
}
int main()
{
int n;
cin >> n;
cout << findone(n) << endl;
cout << func(n) << endl;
return 0;
}