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<iostream>
using namespace std;
char a[100];
int Bin(int n)
{
int j = 1;
while(n>=2)
{
a[j++] = n%2+'0';
n = n/2;
}
a[j] = n+'0';
return j;
}
int main(void)
{
int n;
while(~scanf("%d",&n))
{
int count = Bin(n);
for(int i=count;i>0;--i)
printf("%c",a[i]);
printf("\n");
}
return 0;
}