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>
#define maxn 100000
int main()
{
int x;
int a[maxn];
int count,i,n;
while(scanf("%d",&x)==1)
{
for(i=0; ; i++)
{
n=0;
n=x % 2;
a[i] = n;
x = (x-n)/2;
count = i;
if (x<1)
break;
}
for(i=count; i>=0; i--)
printf("%d",a[i]);
printf("\n");
}
return 0;
}