您的位置:首页 > 编程语言 > C语言/C++

hdu2051 Bitset(C语言)

2017-07-28 11:13 281 查看
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

 

Author

8600 && xhd

 

Source

校庆杯Warm Up

C语言AC代码
#include<stdio.h>
int main()
{
int i,n,t,a[10000];
while(scanf("%d",&n)!=EOF)
{
for(i=0;n>0;i++)
{
a[i]=n%2;
n=n/2
4000
;
t=i;
}
for(i=t;i>=0;i--)
printf("%d",a[i]);
printf("\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: