文章
49
粉丝
90
获赞
9
访问
29.8k
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n;
cin >> n;
string s;
while (n)
{
s += n % 2 + '0';
n /= 2;
}
int count0 = 0, count1 = 0;
for (auto i = s.begin(); i != s.end(); i++)
{
if (*i == '1')
{
count1++;
}
}
count0 = 32 - count1;
cout << "count0=" << count0 << " " << "count1=" << count1 << endl;
return 0;
}
登录后发布评论
暂无评论,来抢沙发