HDU 2051 Bitset

淡定的小魚發表於2014-07-31

/*
中文題意:
中文翻譯:給你一個十進位制數,讓你輸出二進位制數
題目大意:
解題思路:按照一般的方法寫即可
難點詳解:
關鍵點:進位制轉換
解題人:lingnichong
解題時間:2014/07/31       19:23:17
解題感受:要看懂題意,一開始看到測試資料就知道二進位制轉換,但不放心,還是認真看了一下。
*/


Bitset

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 12425    Accepted Submission(s): 9562


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 a[110];
int  main()
{
	int n,i,j;
	while(scanf("%d",&n)!=EOF)
	{
		j=0;
		while(n)
		{
			a[j++]=n%2;
			n/=2;
		}
		for(i=j-1;i>=0;i--)
		printf("%d",a[i]);
		printf("\n");
	}
	return 0;
}