Description
Professor Tom is to teach a graduate course on genes, one thing made him quite a headache: there are tens of thousands of base pairs on a chromosome, they are numbered from 0 to millions, tens of millions, or billions.
For example, when the students about the bases at position No. 1234567009, the light looks figures are difficult to accurately read out.
So, he desperately needs a system, and then when he entered 1,234,567,009 time, will give the corresponding read the law:
1,234,567,009
represented as Pinyin
shi er yi san qian si bai wu shi liu wan qi qian ling jiu
so he only needs to read shining on it.
Your task is to help him design a system like this: Given a string of digits, you help him into reading and writing Chinese Pinyin string accordance with the norms of the adjacent two syllables with a lattice open spaces.
Note must be in strict accordance with specifications, such as "10010" is read as "yi wan ling yi shi" instead of "yi wan ling shi", " 100000" is read as "shi wan" instead of "yi shi wan", "2000 " read as "er qian" instead of "liang qian".
For example, when the students about the bases at position No. 1234567009, the light looks figures are difficult to accurately read out.
So, he desperately needs a system, and then when he entered 1,234,567,009 time, will give the corresponding read the law:
1,234,567,009
represented as Pinyin
shi er yi san qian si bai wu shi liu wan qi qian ling jiu
so he only needs to read shining on it.
Your task is to help him design a system like this: Given a string of digits, you help him into reading and writing Chinese Pinyin string accordance with the norms of the adjacent two syllables with a lattice open spaces.
Note must be in strict accordance with specifications, such as "10010" is read as "yi wan ling yi shi" instead of "yi wan ling shi", " 100000" is read as "shi wan" instead of "yi shi wan", "2000 " read as "er qian" instead of "liang qian".
Input
There is a string of numbers, the numerical size of not more than 2,000,000,000.
Output
Is a string of lower case letters, spaces and commas composition, it represents the number of English reading.
Sample Input
1234567009
Sample Output
shi er yi san qian si bai wu shi liu wan qi qian ling jiu
Meaning of the questions is very simple, patient analysis, simulation and then get away.
Can be found in every four into a group, in the middle billion in Wan connected relatively simple.
Will be divided into good set of four bits of each number separately to determine what
There is a ten shi, yi shi two possibilities based on one hundred cases, such as 1011 are: yi qian ling shi yi, instead of yi qian ling yi shi yi
Note ling and output spaces
Pronunciation uncertainty can go to this website to check online:
http://www.nicetool.net/embed/number_to_chinese.html
1 #include <stdio.h> 2 #include <string.h> 3 #include <iostream> 4 #include <string> 5 #include <math.h> 6 #include <algorithm> 7 #include <vector> 8 #include <stack> 9 #include <queue> 10 #include <set> 11 #include <map> 12 #include <sstream> 13 const int INF=0x3f3f3f3f; 14 typedef long long LL; 15 const int mod=1e9+7; 16 const int maxn=1e4+10; 17 using namespace std; 18 19 map<int,string> mp; 20 21 int main() 22 { 23 #ifdef DEBUG 24 freopen("sample.txt","r",stdin); 25 #endif 26 27 mp[0]="ling";mp[1]="yi"; mp[2]="er"; mp[3]="san"; mp[4]="si"; mp[5]="wu"; 28 mp[6]="liu"; mp[7]="qi"; mp[8]="ba"; mp[9]="JIU " ; MP [ 10 ] = " Shi " ; 29 30 int n-; 31 is CIN >> n-; 32 int T, A, B, C, D; 33 is int F1 = 0 , F2 = 0 ; 34 is IF (n-> = 100000000 ) // process "100 million" before 35 { 36 F1 = . 1 ; 37 [ T = n-/ 100000000 ; 38 is A = T / 10 ; 39 B =% T 10; 40 if(a) 41 { 42 if(a>1) cout<<mp[a]<<" "; 43 cout<<"shi"; 44 if(b) cout<<" "<<mp[b]; 45 } 46 else cout<<mp[b]; 47 cout<<" "<<"yi"; 48 if(n%100000000) cout<<" ";// if the latter is not 0, the partition 49 } 50 IF (n-% 100000000 > = 10000 ) // process "Wan" Before 51 is { 52 is F2 = . 1 ; 53 is T = (n-% 100000000 ) / 10000 ; 54 is A = T / 1000 ; 55 B =% T 1000 / 100 ; 56 is C% T = 100 / 10 ; 57 is D% = T 10 ; 58 IF (A) 59 { 60 cout<<mp[a]<<" qian"; 61 if(b||c||d) cout<<" "; 62 } 63 else if(f1) cout<<"ling "; 64 if(b) 65 { 66 cout<<mp[b]<<" bai"; 67 if(c||d) cout<<" "; if71 { 70ELSE69 } 68 ((a&&c)||(a&&d)) cout<<"ling "; 72 } 73 if(c) 74 { 75 if(c>1) cout<<mp[c]<<" "; 76 cout<<"shi"; 77 if(d) cout<<" "; 78 } 79 else 80 { 81 if(b&&d) cout<<"ling "; if83 } 82 (D) << COUT MP [D]; 84 COUT << " " << " WAN " ; 85 IF (n-% 10000 ) COUT << " " ; // if the latter is not 0, the partition 86 } 87 IF ( % n- 10000 ) 88 { 89 T = (n-% 10000 ); 90 A = T / 1000 ; 91 is B% T = 1000 / 100 ; 92 C% T = 100 / 10; 93 d=t%10; 94 if(a) 95 { 96 cout<<mp[a]<<" qian"; 97 if(b||c||d) cout<<" "; 98 } 99 else if(f2) cout<<"ling "; 100 if(b) 101 { 102 cout<<mp[b]<<" bai"; 103 if(c||d) cout<<" "; 104 } 105 else 106 { 107 if((a&&c)||(a&&d)) cout<<"ling "; 108 } 109 if(c) 110 { 111 if(c>1) cout<<mp[c]<<" "; 112 cout<<"shi"; 113 if(d) cout<<" "; 114 } 115 else 116 { 117 if(b&&d) cout<<"ling "; 118 } 119 if(d) cout<<mp[d]; 120 } 121 cout<<endl; 122 123 return 0; 124 }
I wrote a little trouble, recommended a simple blog writing:
https://blog.csdn.net/weixin_43804406/article/details/104126113
-