文章

93

粉丝

56

获赞

284

访问

37.0k

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

#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;
}

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发