文章

12

粉丝

0

获赞

3

访问

203

头像
二进制数 题解:
P1380 北京邮电大学机试题
发布于2026年3月14日 21:18
阅读数 20

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm> 
#include<string>
#include<cstring>
using namespace std;
int main()
{   
    unsigned int a;
    int res[32] = { 0 };
    while (cin >> a) {
        for (int i =0; i <32; i++) {
            res[i] = ((a >> (31 - i)) & 1);
        }
        int x = 1;
        for (int j = 0; j < 32; j++) {
            if (res[j] != 0) x = 0;
            if (x == 0) cout << res[j];
        }
        if (x == 1) cout << 0;
        cout << endl;
    }
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发