PAT B 1052 (C ++) - Long brush brother's title path

Sell Meng 1052 (20 minutes)
Mengmeng pyridazin emoticons usually consists of "hand", "eyes", "mouth" of three main parts. For simplicity, we assume a symbolic expression is output in the following format: Here Insert Picture Description
a set of symbols now given the choice, would you please according to the user's requirements output expressions.

Input format:
input order corresponding to the first three lines of the previous shots, selectable symbol set eyes, mouth. Each symbol enclosed in square brackets [] within. Title ensure that each set has at least one symbol, the symbol is not more than 10; each symbol contains one to four non-null character. After the line is given a positive integer K, the number of user requests. Then K rows each user is given a symbol selection, the order of the left hand, the left eye, mouth, eye, hand - just to give symbol number in the respective set (starting at 1), a space between the numbers separated.

Output format:
a request for each user generated in the output line expression. If the user selects the serial number does not exist, then the output Are you kidding me? @ / @ .

Sample input:
[╮] [╭] [O] [ ] [/ ] [<] [>]
[╯] [╰] [^] [-] [=] [>] [<] [@] [⊙ ]
[Д] [▽ to] [_] [[epsilon]] [^] ...
. 4
. 1. 1 2 2 2
. 6. 8. 1. 5. 5
. 3. 3. 4. 3. 3
2. 9. 3 10. 3

Output Sample:
╮ (╯ ▽ to ╰) ╭
<(Д = @) / ~
O ( [epsilon] ) O
Are you kidding Me @ / @ V?

Outline of Solution: complex input, first with cin read line by line, to read the vector stored in the symbol, the last symbol needs to read from the vector, the output can be

#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
	string line;
	int num = 0;
	vector<vector<string>> s;
	for (int i = 0; i < 3; i++){
		getline(cin, line);
		vector<string> x;
		int j = 0,k=0;
		while (j < line.length()){
			if (line[j] == '['){
				while (k++ < line.length()){
					if (line[k] == ']'){
						x.push_back(line.substr(j+1,k-1-j));
						break;
					}
				}
			}
			j++;
		}
		s.push_back(x);
	}
	cin >> num;
	for (int i = 0; i < num; i++){
		int l_hand = 0, l_eye = 0, m = 0, r_eye = 0, r_hand = 0;
		cin >> l_hand >> l_eye >> m >> r_eye >> r_hand;
		if (l_hand > s[0].size() || l_eye > s[1].size() || m > s[2].size() || r_eye > s[1].size() || r_hand > s[0].size() || l_hand<1 || l_eye<1 || m<1 || r_hand<1 || r_eye<1){
			cout << "Are you kidding me? @\\/@"<< endl;
		}
		else{
			cout << s[0][l_hand - 1] <<"("<< s[1][l_eye-1] << s[2][m-1] << s[1][r_eye-1] <<")" << s[0][r_hand-1] << endl;
		}
	}
	return 0;
}
Published 52 original articles · won praise 0 · Views 698

Guess you like

Origin blog.csdn.net/qq_23079139/article/details/104112429