1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int i,j; 6 long long n; 7 int a[100]; 8 while(scanf("%lld",&n)!=EOF) 9 { 10 i=0; 11 if(n==0) puts("0"); 12 else{ 13 while(n) 14 { 15 a[i++]=n%2; 16 n/=2; 17 } 18 for(j=i-1;j>=0;j--) 19 printf("%d",a[j]); 20 puts(""); 21 } 22 } 23 system("pause"); 24 return 0; 25 }
好像不能用itoa函数求进制