#include <stdio.h>
int main()
{
int x;
int mask=1; //用来判断位数
do{
scanf("%d",&x);
}while(x>100000||x<-100000); //判断是否在输入范围内
if(x<0){
printf("fu ");
x=-x;
} //正负
int b=x; //暂时寄存x
while(b>9){
b/=10;
mask*=10; //比如x=123 要循环两次 mask就为100,后面这个while循环就结束了,接着x=23,mask=10,x=3,mask=1
}
int a;
while(mask>0)
{
a=x/mask; //用来分解x
x%=mask;
mask/=10;
switch (a){
case 0:
printf("ling");
break;
case 1:
printf("yi");
break;
case 2:
printf("er");
break;
case 3:
printf("san");
break;
case 4:
printf("si");
break;
case 5:
printf("wu");
break;
case 6:
printf("liu");
break;
case 7:
printf("qi");
break;
case 8:
printf("ba");
break;
case 9:
printf("jiu");
break;
}
if(mask>0)
printf(" "); //最后一位数后面不输出空格
}
return 0;
}
#include <stdio.h>
int main()
{
int number;
scanf("%d", &number);//123
if (number < 0)
{
printf("fu ");
number = -number;
}
int temp = number;//123
int cnt = 1;
while (temp > 9)
{
temp /= 10;//12 1
cnt *= 10; //10 10
}
while ( cnt > 0)
{
int i; //12
i = number / cnt; //12 1
switch (i)
{
case 0:
printf("ling");
break;
case 1:
printf("yi");
break;
case 2:
printf("er");
break;
case 3:
printf("san");
break;
case 4:
printf("si");
break;
case 5:
printf("wu");
break;
case 6:
printf("liu");
break;
case 7:
printf("qi");
break;
case 8:
printf("ba");
break;
case 9:
printf("jiu");
break;
}
number %= cnt;//3
cnt /= 10;//1 1
if (cnt > 0)
{
printf(" ");
}
}
return 0;
}