PTA_L1-007念数字
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/821c0ed5594ae771ffdeda927b894e8a.png)
#include<iostream>
using namespace std;
void fun(int n)
{
int i,m,len=0,num=n;
while(num!=0)
{
num/=10;
len++;
}
int a[len];
for(i=0;i<len;i++)
{
a[i]=n%10;
n/=10;
}
for(i=len-1;true;)
{
m=a[i];
switch(m)
{
case 0:cout<<"ling";break;
case 1:cout<<"yi";break;
case 2:cout<<"er";break;
case 3:cout<<"san";break;
case 4:cout<<"si";break;
case 5:cout<<"wu";break;
case 6:cout<<"liu";break;
case 7:cout<<"qi";break;
case 8:cout<<"ba";break;
case 9:cout<<"jiu";break;
}
i--;
if(i<0)
break;
cout<<" ";
}
}
int main()
{
int n;
cin>>n;
if(n==0)
cout<<"ling";
else if(n<0)
{
cout<<"fu"<<" ";
fun(abs(n));
}
else
fun(n);
return 0;
}