看到二进制就要想到bitset
#include<bitset>
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
bitset<32> b(n);
cout<<b.count();
}
看到二进制就要想到bitset
#include<bitset>
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
bitset<32> b(n);
cout<<b.count();
}