PAT~ B ~1052 sell Meng ~C++

Title Description:

Meng Meng Da's emoticons usually consist of three main parts: "hand", "eye" and "mouth". For simplicity, let's assume that an emoticon is output in the following format:

[left hand] ([left eye] [mouth] [right eye]) [right hand]

Given an optional set of symbols, please output the expression according to the user's requirements.

Input format:

Input first gives an optional set of symbols for hand, eye and mouth in the first three rows. Each symbol is enclosed in a pair of brackets []. The Title guarantees that each set has at least one symbol, not more than 10 symbols; each symbol contains 1 to 4 non-empty characters.

The next line gives a positive integer K, the number of requests for the user. Then K lines, each line gives a user's choice of symbols, in the order of left hand, left eye, mouth, right eye, right hand --- here only gives the serial number of symbols in the corresponding set (starting from 1), and the numbers are separated by spaces.

Output format:

For each user request, the generated expression is output in one line. If the serial number selected by the user does not exist, the output is Are you kidding me?@/@.

Input sample:

[╮][╭][o][~\][/~]  [<][>]
 [╯][╰][^][-][=][>][<][@][⊙]
[Д][▽][_][ε][^]  ...
4
1 1 2 2 2
6 8 1 5 5
3 3 4 3 3
2 10 3 9 3

Output sample:

╮(╯▽╰)╭
<(@Д=)/~
o(^ε^)o
Are you kidding me? @\/@

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
    vector<string> shou,yan,kou;
    string temp1,temp2;
    for(int i=0;i<3;i++)
    {
        getline(cin,temp1);
        int flag=0,cur=0;
        char c;
        for(int j=0;j<temp1.length();j++)
        {
            if(temp1[j] == ']')
            {
                flag = 0;
                if(i==0)  
                {
                    shou.push_back(temp2);
                }
                if(i==1) 
                {
                    yan.push_back(temp2);
                }
                if(i==2) 
                {
                    kou.push_back(temp2);
                }
                temp2 = "";
                cur++;
            }
            if(c == '[' || flag==1)
            {
                flag = 1;
                temp2 += temp1[j];
            }
            
            c = temp1[j]; 
        }
    }
    int num,temp[5];
    cin>>num;
    while(num--)
    {
        cin>>temp[0]>>temp[1]>>temp[2]>>temp[3]>>temp[4];
        if(temp[0]-1 < shou.size() && temp[1]-1 < yan.size() && temp[2]-1 < kou.size() && temp[3]-1 < yan.size() && temp[4]-1 < shou.size())
        {
           cout<<shou[temp[0]-1]<<'('<<yan[temp[1]-1]<<kou[temp[2]-1]<<yan[temp[3]-1]<<')'<<shou[temp[4]-1]<<endl;
        }
        else
        {
            cout<<"Are you kidding me? @\\/@"<<endl;
        }
    }
    return 0;
}

Maintain a shared document of PAT test point problems. Welcome to write the problems you encounter on it.

Write a document together: https://yiqixie.com/d/home/fcACe6xZ2aroPxFQrQZ05Cw32
Github link: https://github.com/Makerdd/PAT-yiji

 

 

 

 

Keywords: github

Added by gr00 on Wed, 02 Oct 2019 02:56:57 +0300