32 lines
568 B
C
32 lines
568 B
C
#include <stdio.h>
|
|
|
|
char *map[] = {
|
|
"ling", "yi", "er", "san", "si",
|
|
"wu", "liu", "qi", "ba", "jiu"
|
|
};
|
|
|
|
void display_num_with_pinyin(int num)
|
|
{
|
|
char *stack[10] = {0,};
|
|
int stack_top = 0;
|
|
char *sign = "";
|
|
if (num < 0) {
|
|
sign = "fu ";
|
|
num = -num;
|
|
}
|
|
for (; num; num = num / 10) {
|
|
stack[stack_top++] = map[num % 10];
|
|
}
|
|
printf("%s", sign);
|
|
while (--stack_top > -1) {
|
|
printf("%s ", stack[stack_top]);
|
|
}
|
|
printf("\b\n");
|
|
}
|
|
|
|
int main()
|
|
{
|
|
display_num_with_pinyin(-6543210);
|
|
return 0;
|
|
}
|