位运算这样写也是可以的
#include<iostream>
using namespace std;
int main()
{
int n;
while(cin>>n){
int res=0;
while(n){
n-=n&-n;
res++;
}
cout<<res<<endl;
}
return 0;
}
位运算这样写也是可以的
#include<iostream>
using namespace std;
int main()
{
int n;
while(cin>>n){
int res=0;
while(n){
n-=n&-n;
res++;
}
cout<<res<<endl;
}
return 0;
}