2 read integer (5 points)
Subject content:
Your program to read an integer range is (000-100000100), then use Chinese pinyin to the integer each output,
1234 as input, output:
Yi er SAN si
Note that there is a space between the pinyin of each word, but in the end there is no space behind the words that, when faced with a negative number in the output at the beginning of the "fu", such as - 2341 output for:
Fu er SAN si yi
Input format:
An integer, the range is (000-100000100),
The output format:
Said every digits of the integer hanyu pinyin, each digit of pinyin are separated by Spaces, no Spaces at the end,
Input the sample:
- 30
The output sample:
Fu SAN ling
Time limit: 500 ms memory limit: 32000 KB
Code:
# include & lt; stdio.h>
Int place_value (int n)
{
Int j=1;
for (int i=1; I & lt; n; I++)
{
J *=10;
}
Return j;
}
Int main (void)
{
Int n, I, j=0, t, m;
The scanf (" % d ", & amp; n);
If (n & lt; 0)
{
Printf (" fu ");
N=n - n * 2;
}
M=n;
Do
{
M/=10;
j++;
} while (m & gt; 0);
For (; J & gt; 0; J -)
{
T=n/place_value (j);
The switch (t)
{
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;
Default:
break;
}
If (place_value (j) & gt; 1)
printf(" ");
N=n - t * place_value (j);
}
return 0;
}
Code is to China university mooc upload above, why line sixty-eight, please write to: if (n & gt; 9), submitted a case shows that the output format is wrong?