1082 Read Number in Chinese (25 分)

时间:2023-11-25 17:58:32
1082 Read Number in Chinese (25 分)

Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. Output Fufirst 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

分析: 这个题有点复杂。。慢慢模拟。。debug了好久,要注意一个数中间空了多个零,只要输出一个零。。。

一开始没注意,女朋友随便给我出了个数。。竟然真错在这里了,她是不是有干测试的潜质= =

 /**
 * Copyright(c)
 * All rights reserved.
 * Author : Mered1th
 * Date : 2019-02-24-22.11.37
 * Description : A1082
 */
 #include<cstdio>
 #include<cstring>
 #include<iostream>
 #include<cmath>
 #include<algorithm>
 #include<string>
 #include<unordered_set>
 #include<map>
 #include<vector>
 #include<set>
 using namespace std;
 ]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};
 ]={"Yi","Wan"};

 void func(int n){
     string s=to_string(n);
     ){
         cout<<num[s[]-'];
     }
     ){
         cout<<num[s[]-']<<" "<<"Shi";
         ]!='){
             cout<<]-'];
         }
     }
     ){
         cout<<num[s[]-']<<" "<<"Bai";
         ]=='){
             ]!='){
                 cout<<]-'];
             }
         }
         else{
             cout<<]-']<<" Shi";
             ]!='){
                 cout<<]-'];
             }
         }
     }
     ){
         cout<<num[s[]-']<<" Qian";
         ]=='){
             ]=='){
                 ]!='){
                     cout<<]-'];
                 }
             }
             else{
                 cout<<]-']<<" Shi";
                 ]!='){
                     cout<<]-'];
                 }
             }
         }
         else{
             cout<<]-']<<" Bai";
             ]=='){
                 ]!='){
                     cout<<]-'];
                 }
             }
             else{
                 cout<<]-']<<" Shi";
                 ]!='){
                     cout<<]-'];
                 }
             }
         }
     }
 }

 int main(){
 #ifdef ONLINE_JUDGE
 #else
     freopen("1.txt", "r", stdin);
 #endif
     int s;
     cin>>s;
     ){
         printf("ling");
         ;
     }
     ){
         printf("Fu ");
         s=-s;
     }
     ;
     /;
     ;
     bool flag=false;
     if(s1){
         func(s1);
         cout<<]<<" ";
     }
     if(s2){
         string t2=to_string(s2);
         ){
             ;i<=t2.size();i++){
                 '){
                     cout<<"ling ";
                 }
             }
         }
         func(s2);
         cout<<]<<" ";
     }
     if(s3){
          && s2==){
             cout<<"ling ";
             flag=true;
         }
         string t3=to_string(s3);
         ){
             ;i<=t3.size();i++){
                 ' && flag==false){
                     cout<<"ling ";
                     flag=true;
                 }
             }
         }
         func(s3);
     }
     ;
 }