PAT真题练习乙级1002

/*PAT真题练习乙级1002*/
#include
#include
#include
int main()
{    
	int sum=0,s1[4]={0};    
	char num[101];    
	char pinyin[10][6]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};     
	gets(num);    
	for(int i=0;num[i]!=0;i++)    
	{        
		sum+=(num[i]-48);    
	}    
	int j=0;    
	while(sum!=0)   
 	{       
  		s1[j]=sum%10;        
  		sum=sum/10; 
        j++;
    }    
    for(int k=j-1;k>=0;k--)
    {
        printf("%s%c",pinyin[s1[k]],k==0?'\n':32); 
    }    
    return 0;
}


你可能感兴趣的:(PAT真题练习乙级1002)