HDU_2051——十进制到二进制转换

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 <cstdio>
int main()
{
int n, i, ans[];
while(~scanf("%d",&n))
{
if(n==)
{
printf("0\n");
}
for(i=;n;i++)
{
ans[i]=n%;
n=n/;
}
for(i--;i>=;i--)
{
printf("%d",ans[i]);
}
printf("\n");
}
return ;
}
上一篇:MOCKITO 应用示例


下一篇:mysql事务、redo日志、undo日志、checkpoint详解