ocrosoft Contest1316

http://acm.ocrosoft.com/problem.php?cid=1316&pid=49

题目描述

把十进制到二进制的转换。

输入

234

输出

11101010

样例输入

234

样例输出

11101010

代码:

#include <bits/stdc++.h>
using namespace std;
 
const int maxn = 1e5 + 10;
int N;
int a[maxn];
 
int main() {
    scanf("%d", &N);
 
    int num = 0;
    while(N) {
        a[num ++] = N % 2;
        N /= 2;
    }
 
    for(int i = num - 1; i >= 0; i --)
        printf("%d", a[i]);
    printf("
");
 
    return 0;
}
 

  

原文地址:https://www.cnblogs.com/zlrrrr/p/9726637.html