Basic Level 1052 sell cute (20 points)

topic

Moe Meng Da emoji usually consists of three main parts: "hand", "eye", and "mouth". For simplicity, we assume that an emoji is output in the following format:

[左手]([左眼][][右眼])[右手]

Here is a set of optional symbols, please output emoticons according to the user's requirements.

Input format:

The input first corresponds to the optional symbol set of hand, eye, and mouth in the first three rows. Each symbol is enclosed in square brackets []. The title guarantees that each set has at least one symbol and no more than 10 symbols; each symbol contains 1 to 4 non-blank characters.

The next line gives a positive integer K, which is the number requested by the user. Then K lines, each line gives a user's symbol selection, the order is left hand, left eye, mouth, right eye, right hand-here only the sequence number of the symbol in the corresponding set (starting from 1) is given, with spaces between the numbers Separated.

Output format:

For each user request, output the generated expression in one line. If the serial number selected by the user does not exist, the output 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

Sample output:

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

Code:

#include <iostream>
#include <vector>
using namespace std;
int main(){
    
    
    vector<vector<string>> v;
    for(int i = 0; i < 3; i++){
    
    
        string s;
        getline(cin, s);
        vector<string> row;
        int k = 0;
        for(int j = 0; j < s.length(); j++)
            if(s[j] == '[')
                while(k++ < s.length())
                    if(s[k] == ']'){
    
    
                        row.push_back(s.substr(j + 1, k - j - 1));
                        break;
                    }
        v.push_back(row);
    }
    int n, q[5];
    cin >> n;
    for(int i = 0; i < n; i++){
    
    
        cin >> q[0] >> q[1] >> q[2] >> q[3] >> q[4];
        if(q[0] > v[0].size() || q[1] > v[1].size() || q[2] > v[2].size() || q[3] > v[1].size() || q[4] > v[0].size() || q[0] < 1 || q[1] < 1 || q[2] < 1 || q[3] < 1 || q[4] < 1){
    
    
            cout << "Are you kidding me? @\\/@" << endl;
            continue;
        }
        cout << v[0][--q[0]] << "(" << v[1][--q[1]] << v[2][--q[2]] << v[1][--q[3]] << ")" << v[0][--q[4]] << endl;
    }
    return 0;
}

PAT_BasicLevel

Guess you like

Origin blog.csdn.net/zy440458/article/details/113810228