0和1的个数 题解:暴力
#include <bits/stdc++.h>
using namespace std;
int num[32]={0};
int main()
{
int n;
cin>>n;
int count0=0;
int count1=0;
int j=0;
while(j<32)
{
num[j]=n%2;
n/=2;
j++;
}
for(int j=31;j>=0;j--)
{
if(num[j]==0)count0++;
else count1++;
}
cout<<"count0="<<count0<<' '<<&quo...
登录后发布评论
暂无评论,来抢沙发