//10的100次方一共101位数 #include <stdio.h> int main() { int indexNum = 0;int sum = 0;char num[101] = {0};char result[10] = {0};int indexResult = 0;int aa = 0; scanf("%s",&num); char pinyin[10][5] = {"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};//构造一个10*10的矩阵另外多加一行 while(num[indexNum] != '\0') { sum += num[indexNum] - '0';//字符转数字 indexNum++; } while(sum != 0) { result[indexResult] = sum % 10;//注意先得到的是个位,依次.. sum /= 10; indexResult++; } for (int i = indexResult - 1;i >= 0 ;i--) { printf("%s",pinyin[result[i]]); if(i!=0) printf(" "); } }
标签:10,int,sum,indexResult,num,PAT1002,indexNum From: https://www.cnblogs.com/huskyWuWuWu/p/16860304.html