<>PTA— Read numbers (C language ) Two methods

Enter an integer , Output the Pinyin corresponding to each number . When the integer is negative , First output fu word . The Pinyin corresponding to the ten numbers is as follows :
0: ling 1: yi 2: er 3: san 4: si 5: wu 6: liu 7: qi 8: ba 9: jiu
<> Input format :

Input gives an integer in one line , as :1234.

Tips : Integers include negative numbers , Zero and positive numbers .

<> Output format :

Output the Pinyin corresponding to this integer in one line , The Pinyin of each number is separated by a space , There is no last space at the end of the line . as yi er san si.

<> sample input :
-600
<> sample output :
fu liu ling ling
First kind : Related source code
#include<stdio.h> #include<string.h> int main() { char num[20]; int i; scanf(
"%s",&num); for(i=0;i<strlen(num);i++) { switch(num[i]) { case '-':printf("fu");
break; 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(i<strlen(num-1)) printf(" ");// Once per cycle Print a space } return 0; } //2 branch
Second : Related source code
#include<stdio.h> #include<string.h> int main() { char c; c=getchar(); while(c
!='\n') { if(c=='-')printf("fu"); else if(c=='0')printf("ling"); else if(c=='1')
printf("yi"); else if(c=='2')printf("er"); else if(c=='3')printf("san"); else if
(c=='4')printf("si"); else if(c=='5')printf("wu"); else if(c=='6')printf("liu");
else if(c=='7')printf("qi"); else if(c=='8')printf("ba"); else if(c=='9')printf(
"jiu"); c=getchar(); if(c!='\n')printf(" "); // Once per cycle Print a space } return 0; } //10 branch
Although the first one got two points , But there is some logic , If there is any way to improve, you can contact me , Discuss together , thank you !!!
Here's the first improved method , Thank you for your comments
take i<strlen(num-1) Change to i<strlen(num)-1 You can get full marks
#include<stdio.h> #include<string.h> int main() { char num[20]; int i; scanf(
"%s",&num); for(i=0;i<strlen(num);i++) { switch(num[i]) { case '-':printf("fu");
break; 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(i<strlen(num)-1) printf(" ");// Once per cycle Print a space } return 0; } //10 branch

Technology