Bitset hd 2051

来源:互联网 发布:淘宝卖燕窝怎么程序 编辑:程序博客网 时间:2024/05/17 04:15
Problem Description
Give you a number on base ten,you should output it on base two.(0 < n < 1000)


Input
For each case there is a postive number n on base ten, end of file.


Output
For each case output a number on base two.


Sample Input
1
2
3


Sample Output
1
10

11

#include<stdio.h>int main(){    int i,n,m,j,a[100];    while(scanf("%d",&n)!=EOF)    {        i=0;        while(n)        {            i=i+1;            a[i]=n%2;            n/=2;        }        for(i;i>0;i--)            printf("%d",a[i]);        printf("\n");    }    return 0;} 


0 0
原创粉丝点击