本题可以键盘直接接收一个int类型的数,然后去拆分这个数,不用一个一个字符的接收
顺带再练一练递归
#include <stdio.h>
#include <stdlib.h>
char shuzi[10][5] = {"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};
int count = 0;
void printN(int n);
int main(){
int n;
scanf("%d",&n);
if (n<0){
printf("fu ");
printN(abs(n));
}else if(n>0){
printN(n);
}else{
printf("ling");
}
}
void printN(int n){
if(n==0){
return;
}else{
printN(n/10);
if(count==0){
printf("%s",shuzi[n%10]);
count++;
}else{
printf(" %s",shuzi[n%10]);
}
}
}