文章
17
粉丝
133
获赞
4
访问
94.2k
#include<bits/stdc++.h>
using namespace std;
int main(){
int m;
cin >> m;
unsigned int n = static_cast<unsigned int>(m);
string s="";
while(n!=0){
s.append(1, '0'+n%2);
n/=2;
}
while(s.size()<32){
s.append(1, '0');
}
int c0 = count(s.begin(),s.end(),'0');
int c1 = count(s.begin(),s.end(),'1');
cout << "count0="<<c0<<" count1="<<c1;
return 0;
}
登录后发布评论
暂无评论,来抢沙发