Give you a number on base ten,you should output it on base two.(0 < n < 1000) |
For each case there is a postive number n on base ten, end of file. |
For each case output a number on base two. |
1 2 3 |
1 10 11 |
代码实现:
#include <stdio.h>
void TtoB(int n)
{
if (n)
{
TtoB(n >> 1);
printf("%d", n & 1);
}
}
int main(void)
{
int n;
while (scanf("%d", &n) != EOF)
{
TtoB(n);
putchar('\n');
}
return 0;
}