Enter an integer and the pinyin corresponding to each digit. When the integer is negative, the word "Fu" is output first. The 10 digits correspond to the following pinyin:
0: ling1: yi2: er3: san4: si5: wu6: liu7: qi8: ba9: jiu
Input Format:
Enter an integer in a row, for example:1234
.
Tip: integers include negative, zero, and positive.
Output Format:
Output the pinyin corresponding to this integer in one row. the pinyin characters of each number are separated by spaces. There is no final space at the end of the line. For exampleyi er san si
.
Input example:
-600
Output example:
fu liu ling ling
Note: You can also use the switch-case statement to implement this question.
#include "stdio.h"int main(){ int N,t,p,n=0; scanf("%d",&N); t=N; if(N<0) { printf("fu "); N=-N; } if(N==0) { printf("ling"); goto out; } p=N; while(N>9) { N/=10; n++; } int x=1; while(n>0) { x*=10; n--; } int z; do{ z=p/x; if(x>0) { p%=x; //x!=0 } x/=10; if(z==0) { printf("ling"); } else if(z==1) { printf("yi"); } else if(z==2) { printf("er"); } else if(z==3) { printf("san"); } else if(z==4) { printf("si"); } else if(z==5) { printf("wu"); } else if(z==6) { printf("liu"); } else if(z==7) { printf("qi"); } else if(z==8) { printf("ba"); } else { printf("jiu"); } if(x>0) { printf(" "); } }while(x>0);out: return 0;}
05-2. read numbers (15)