标签:img temp ++ inf alt switch 变量 image 根据
1 #include<stdio.h> 2 3 int pow(int m, int n); 4 int main(void) 5 { 6 int n; 7 int temp; //n的绝对值 8 int count; //数的位数 9 int x; //临时变量 10 11 count = 0; 12 scanf_s("%d", &n); 13 14 temp = n; 15 if (n < 0) 16 { 17 temp = -n; 18 } 19 20 x = temp; 21 22 /*计算位数*/ 23 do 24 { 25 count++; 26 x = x / 10; 27 28 } while (x != 0); 29 30 if (n < 0) 31 { 32 printf("fu "); 33 } 34 35 /*根据位数进行循环*/ 36 for (int i = 1; i <= count; i++) 37 { 38 x = temp / pow(10, count - i); 39 temp = temp % pow(10, count - i); 40 41 switch (x) 42 { 43 case 0:printf("ling"); break; 44 case 1:printf("yi"); break; 45 case 2:printf("er"); break; 46 case 3:printf("san"); break; 47 case 4:printf("si"); break; 48 case 5:printf("wu"); break; 49 case 6:printf("liu"); break; 50 case 7:printf("qi"); break; 51 case 8:printf("ba"); break; 52 case 9:printf("jiu"); break; 53 } 54 if (i != count) 55 { 56 printf(" "); 57 } 58 } while (temp != 0); 59 60 return 0; 61 } 62 63 int pow(int m, int n) 64 { 65 int ret; 66 67 ret = 1; 68 for (int i = 1; i <= n; i++) 69 { 70 ret = ret * m; 71 } 72 73 return ret; 74 }
标签:img temp ++ inf alt switch 变量 image 根据
原文地址:https://www.cnblogs.com/2018jason/p/11927555.html