HDU 4278 Faulty Odometer
http://acm.hdu.edu.cn/showproblem.php?pid=4278
进制转换,以前看过一道十进制转换为十三进制的,现在忘记哪里做过了
0 1 2 3 4 5 6 7 8 9 十进制
0 1 2 3 4 5 6 7 八进制
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <stdio.h> 2 #include <string.h> 3 int main() 4 { 5 long a[10]={0,1,2,0,3,4,5,6,0,7},i,j,sum,k; 6 char s[100]; 7 while(~scanf("%s",&s)){ 8 if(strcmp(s,"0")==0) break; 9 sum=0;k=1; 10 for(i=strlen(s)-1;i>=0;i--) 11 { 12 sum+=a[s[i]-'0']*k; 13 k*=8; 14 } 15 printf("%s: %ld\n",s,sum); 16 } 17 }