每次减一,消除最右边的1
求int型正整数在内存中存储时1的个数
http://www.nowcoder.com/questionTerminal/440f16e490a0404786865e99c6ad91c9
include <bits/stdc++.h>
using namespace std;
int main()
{
int n,count=0;
cin>>n;
while(n)
{
++count;
n = n&(n-1);
}
cout<<count<<endl;
return 0;
}