文章

93

粉丝

56

获赞

264

访问

21.5k

头像
统计二进制数中的1的个数 题解:暴力
P1547 中山大学机试题
发布于2025年3月24日 22:08
阅读数 97

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin>>n;
    string str;
    int ans=0;
    while(n)
    {
        if(n%2==1)ans++;
        n/=2;
    }
    cout<<ans;
    return 0;
}

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发