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<stdio.h>
void main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int i=0;
int a[10];
while(n!=1&&n!=0)
{
a[i]=n%2;
n=n/2;
i++;
}
if(n==0)
printf("%d",0);
else
{
printf("%d",1);
if(i!=0)
{
while(i--)
printf("%d",a[i]);
}
}
printf("\n");
}
}
嗷。就是二进制转换。