您的位置:首页 > 其它

杭电acm--2051

2015-09-20 18:04 309 查看
Give you a number on base ten,you should output it on base two.(0 < n < 1000)

[align=left]Input[/align]
For each case there is a postive number n on base ten, end of file.

[align=left]Output[/align]
For each case output a number on base two.

#include<stdio.h>
#include<stdlib.h>
//#include<string.h>
//#include<math.h>

void main()
{
int n, arr[500], t = 0;
while (scanf("%d", &n) != EOF)
{
for (int i = 0; n!=0; i++)
{
arr[i] = n % 2;
n = n / 2;
t = i;
}
for (int i = t; i >= 0; i--)
printf("%d", arr[i]);
printf("\n");

}

system("pause");
}



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: