AC代码
1 #include <stdio.h> 2 void PrintChn(int num) 3 { 4 int cnt = 0; 5 int tempNum = num; 6 while (tempNum>0) 7 { 8 tempNum = tempNum/10; 9 cnt++; 10 } 11 int i; 12 int mask = 1; 13 for(i = cnt;i > 0;i--) 14 { 15 mask *= 10; 16 } 17 mask = mask/10; 18 while (mask != 0) 19 { 20 int temp = 0; 21 temp = num/mask; 22 num = num % mask; 23 mask = mask/10; 24 switch (temp) 25 { 26 case 0:printf("ling"); 27 break; 28 case 1:printf("yi"); 29 break; 30 case 2:printf("er"); 31 break; 32 case 3:printf("san"); 33 break; 34 case 4:printf("si"); 35 break; 36 case 5:printf("wu"); 37 break; 38 case 6:printf("liu"); 39 break; 40 case 7:printf("qi"); 41 break; 42 case 8:printf("ba"); 43 break; 44 case 9:printf("jiu"); 45 break; 46 } 47 if(mask>0) 48 { 49 printf(" "); 50 } 51 } 52 } 53 int main () 54 { 55 char box[100]; //define "box"char array for input num; 56 scanf("%s",&box); 57 int temp = 0; 58 int i = 0; 59 while(box[i] != 0) 60 { 61 temp += (int)box[i] - ‘0‘; 62 i++; 63 } 64 PrintChn(temp); 65 return 0 ; 66 67 }
时间: 2024-10-23 09:05:17