2019年2月13日
1:03
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
string s;
string c[11] = {"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu"};
string d[4] = {"", "Shi", "Bai", "Qian"};
string e[3] = {"", "Wan", "Yi"};
while(cin >> s)
{
int j = -1;
if(s[0] == '-')
cout << "Fu" << " ", j = 0;
int len;
len = s[0] == '-' ? s.size() - 1 : s.size();
int t = len % 4;
int f = 1, flag = 0;
int k = (len - 1) / 4;
if(len == 1)
{
cout << c[++j] << endl;
continue;
}
while(len != 0)
{
//cout << len << endl;
j++;
len--;
t = len % 4;
//cout << s[j] << endl;
if(s[j] != '0')
{
flag = 1;
if(f == 1)
{
cout << c[s[j] - '0'];
f = 0;
}
else
{
cout << " " << c[s[j] - '0'];
}
if(d[t] != "")
cout << " " << d[t];
}
else
{
//cout << s[j] << endl;
while(s[j] == '0' && t != 0)
{
j++;
len--;
t = len % 4;
//cout << j <<" ";
}
if(t != 0)
{
//cout << t << endl;
cout << " " << c[0] ;
}
else if(s[j - 1] == '0' && s[j] != '0')
cout << " " << c[0];
if(s[j] != '0' )
{
cout << " " << c[s[j] - '0'];
if(d[t] != "")
cout<< " " << d[t] ;
}
}
if(t == 0 && e[k] != "" && flag == 1)
{
//cout <<k << endl;
flag = 0;
cout << " " << e[k--] ;
}
}
cout << endl;
}
return 0;
}
/*
-123456789
100800
123456789
-100800
100000000
10101010
9
-1
100000
108638
24508
23125000
*/