HDoj 2051 Bitset
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
Recommend
C语言代码如下:
#include<stdio.h> int main() { int n=0; int l=0; char s[20]; while(scanf("%d",&n)!=EOF) { l=0; while(n!=0) { s[l++]=n%2; n/=2; } for(int i=l-1;i>=0;i--) printf("%d",s[i]); printf("\n"); } }
浙公网安备 33010602011771号