#include <iostream>
#include<string>
using namespace std;
bool tag=0;
string chinese[10]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};
//string digity[5]={"Shi","Bai","Qian","Wan","Yi"};
void getdigit(int n){
if(n==8) cout<<" Yi";
else if(n==4) cout<<" Wan";
else if(n==7||n==3) cout<<" Qian";
else if(n==6||n==2) cout<<" Bai";
else if(n==5||n==1) cout<<" Shi";
}
//1 3245 6589
//一亿 三千二百四十五万 六千五百八十九
void getnum(int n){
if(tag)cout<<" ";
else tag=1;
cout<<chinese[n];
}
int main()
{
int n;
cin>>n;
if(n==0){
cout<<"ling";
return 0;
}
if(n<0){
cout<<"Fu";
n=-n;
tag=1;
}
int ans[10]={0};
int num=0;
while(n!=0){
ans[num++]=n%10;
n=n/10;
}
for(int i=num-1;i>=0;i--){
if(ans[i]!=0){
getnum(ans[i]);
getdigit(i);
}
else if(i==4)//ans[i]==0 && i==4
cout<<" Wan";
else if(i>0&&ans[i-1]!=0)
getnum(ans[i]);
}
return 0;
}
pat甲级1082
最新推荐文章于 2024-08-19 16:28:10 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)