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
Inputcopy | Outputcopy |
---|---|
1 2 3 | 1 10 11 |
#include<iostream>
using namespace std;
void convert_two(int n){
int t[100],i=0;
while(n!=0){
t[i++]=n%2;
n=n/2;
}
for(int k=i-1;k>=0;k--){
cout<<t[k];
}
cout<<endl;
}
int main(){
int n;
while(cin>>n){
convert_two(n);
}
return 0;
}