The 16th Program Design Competition A-GRE of Xidian University

Topic description

   In order to succeed in research, Wang Mengmeng began to memorize GRE words assiduously, but because she worked so hard, she forgot the Chinese pronunciation while reciting English words. So Wang Mengmeng began to review Chinese pronunciation again, and she began to review the numbers. .
  The question is very simple, Wang Mengmeng gives English words with integers in the range of [0, 10], you teach her Chinese pronunciation.

Enter description:

Enter a T in the first line to indicate the word Wang Mengmeng asked about. (T <= 20) There is one English word per line in the next T lines. The title ensures that the English word is the word represented by the number [0, 10] and the word is written correctly. The word is given in lowercase.

Output description:

For each input word, output its Chinese pronunciation, please give it in lowercase.
Example 1

enter

5
zero
one
one
four
eight

output

ling
yi
yi
and
The code written by ba 
himself is the most stupid method. Since there are only one to ten, you can enumerate all the situations.
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        string ss;
        cin>>ss;
        if(ss[0]=='z')
            cout<<"ling"<<endl;
        else if(ss[0]=='o')
            cout<<"yi"<<endl;
        else if(ss[0]=='e')
            cout<<"ba"<<endl;
        else if(ss[0]=='n')
            cout<<"jiu"<<endl;
        else if(ss[0]=='t'&&ss[1]=='w')
            cout<<"er"<<endl;
        else if(ss[0]=='t'&&ss[1]=='h')
            cout<<"san"<<endl;
        else if(ss[0]=='t'&&ss[1]=='e')
            cout<<"shi"<<endl;
        else if(ss[0]=='s'&&ss[1]=='i')
            cout<<"liu"<<endl;
        else if(ss[0]=='s'&&ss[1]=='e')
            cout<<"qi"<<endl;
        else if(ss[0]=='f'&&ss[1]=='i')
            cout<<"wu"<<endl;
        else cout<<"si"<<endl;
    }
}

The code written by the big guy, use map to map Chinese and English one by one

#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<string,string>number;
    number["zero"]="ling";
    number["one"]="yi";
    number["two"]="er";
    number["three"]="san";
    number["four"]="si";
    number["five"]="wu";
    number["six"]="liu";
    number["seven"]="qi";
    number["eight"]="ba";
    number["nine"]="jiu";
    number["ten"]="shi";
    int n;
    string s;
    cin>>n;
    while(n--)
    {
        cin>>s;
        cout<<number[s]<<endl;
    }
    return 0;
 }

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324686991&siteId=291194637