Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fu first if it is negative. For example, -123456789 is read as Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiu. Note: zero (ling) must be handled correctly according to the Chinese tradition. For example, 100800 is yi Shi Wan ling ba Bai.
Input Specification:
Each input file contains one test case, which gives an integer with no more than 9 digits.
Output Specification:
For each test case, print in a line the Chinese way of reading the number. The characters are separated by a space and there must be no extra space at the end of the line.
Sample Input 1:
-123456789
Sample Output 1:
Fu yi Yi er Qian san Bai si Shi wu Wan liu Qian qi Bai ba Shi jiu
Sample Input 2:
100800
Sample Output 2:
yi Shi Wan ling ba Bai
仔细想其实题目不难
零 出现之后记录他 遇到非零的就把这个记录加进答案 答案清零
当零出现在万位 亿位 要输出Wan&&Yi
#include <bits/stdc++.h>
using namespace std;
string aa[10]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};
string ss[9]={"","Shi","Bai","Qian","Wan","Shi","Bai","Qian","Yi"};
vector<string> ans;
void print(){
for(int i=0;i<ans.size();++i){
printf("%s%c",ans[i].c_str(),i==ans.size()-1?'\n':' ');
}
}
void solve(){
string str;
ans.clear();
cin>>str;
if(str=="0"){
cout<<aa[0]<<endl;
}
else{
if(str[0]=='-'){
ans.push_back("Fu");
str = str.substr(1);
}
int len = str.size();
bool zero=false;
for(int i=0;i<len;++i){
int rem = len-i-1;
if(str[i]!='0'){
if(zero){
ans.push_back(aa[0]);
zero = false;
}
int temp = str[i]-'0';
ans.push_back(aa[temp]);
if(ss[rem].size()){
ans.push_back(ss[rem]);
}
}
else{
zero = true;
if(rem==4||rem==8){
ans.push_back(ss[rem]);
}
}
}
print();
}
}
int main(){
solve();
return 0;
}