念数字
Time Limit: 1000/1000MS (C++/Others) Memory Limit: 65536/65536KB (C++/Others)
Total Submissions: 4 Accepted Submissions: 1
Problem Description
输入一个整数,输出每个数字对应的拼音。当整数为负数时,先输出fu字。十个数字对应的拼音如下:
0: ling
1: yi
2: er
3: san
4: si
5: wu
6: liu
7: qi
8: ba
9: jiu
Input
输入有多行,每行一个整数,如:1234。
Output
输出每行整数对应的拼音,每个数字的拼音之间用空格分开,行末没有最后的空格。如 yi er san si。
Sample Input
-600
Sample Output
fu liu ling ling
#include <stdio.h>
int main()
{
char s[10][6] = {"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};
int num;
int base;
while(~scanf("%d",&num))
{
if(num==0)
printf("ling\n");
else
{
if(num<0)
{
printf("fu ");
num = -num;
}
int res[100];
int i = 0;
while(num!=0)
{
res[i++] = num%10;
num /= 10;
}
i--;
for(;i>=0;i--)
{
printf("%s",s[res[i]]);
if(i!=0) printf(" ");
else printf("\n");
}
}
}
return 0;
}