杭电acm2051

View Code
 1 #include<stdio.h>
 2 #include<string.h>
 3 int main()
 4 {
 5  int n,i;
 6  char s[10000];
 7  while(scanf("%d",&n)!=EOF)
 8    {
 9     i=0;
10     while(n/2)
11       {
12        s[i++]=n%2+'0';
13        n/=2;
14       }
15     s[i++]=n+'0';
16     for(i--;i>=0;i--)
17       printf("%c",s[i]);
18     printf("\n");
19    }
20  return 0;
21 }

http://acm.hdu.edu.cn/showproblem.php?pid=2051

进制间的转化,只需要除k取余,然后反过来输出就正确了

原文地址:https://www.cnblogs.com/huzhenbo113/p/2983275.html