HDU_oj_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
分析:
十进制数转为二进制
注意点:
1 #include<iostream> 2 using namespace std; 3 4 int main() 5 { 6 int n; 7 int c[35]; 8 while(cin>>n) 9 { 10 int i=1; 11 while(n) 12 { 13 int v=n%2; 14 n>>=1; 15 c[i++]=v; 16 } 17 while(--i) 18 cout<<c[i]; 19 cout<<endl; 20 } 21 }