做法非常巧妙(这也是我看别人的写法写的)
#include <string.h>
#include <stdio.h>
int main()
{
int i = 0;
char str[100000] = { '\0'};
char arr[10][5] = { "ling","yi","er","san","si","wu","liu","qi","ba","jiu" };
int n = 0;
scanf("%s",str);
if( str[0] == '-' )如果数是负数,则第一个字符是'-'
{
printf("fu");
}
else(其余就是正数 0 )
{
printf("%s",arr[str[0]-'0']); //这里解析出来是arr行的首地址 , 因此需用%s打印
}
for( i = 1 ; i < strlen(str) ; i++)
{
printf(" %s",arr[str[i]-'0']);
}
return 0;
}