Give you a number on base ten,you should output it on base two.(0 < n < 1000)
InputFor each case there is a postive number n on base ten, end of file.OutputFor each case output a number on base two.Sample Input
1
2
3
Sample Output
1
10
11
#include<stdio.h>
int main()
{
int n,k,t;
while(scanf("%d",&n)!=EOF)
{
k=0;
t=1;
while(n!=0)
{
k+=(n%2)*t;
n=n/2;
t*=10;
}
printf("%d\n",k);
}
return 0;
}
题解:多么可爱的水题!