题目:https://pintia.cn/problem-sets/994805260223102976/problems/994805273883951104
代码
#include<cstdio>#include<vector>#include<string>#include<iostream>using namespace std;int main(){string temp_str;vector<string>hands, eyes, mouth;int temp[5];getline(cin, temp_str);for(int i = 0; i < temp_str.size();){if(temp_str[i] == '['){for(int j = i; j < temp_str.size(); j++){if(temp_str[j] == ']'){hands.push_back(temp_str.substr(i + 1, j - i -1));//cout<<temp_str.substr(i + 1, j - i -1);i = j + 1;break;}}}else i++;}getline(cin, temp_str);for(int i = 0; i < temp_str.size();){if(temp_str[i] == '['){for(int j = i; j < temp_str.size(); j++){if(temp_str[j] == ']'){eyes.push_back(temp_str.substr(i + 1, j - i -1));//cout<<temp_str.substr(i + 1, j - i -1);i = j + 1;break;}}}else i++;}getline(cin, temp_str);for(int i = 0; i < temp_str.size();){if(temp_str[i] == '['){for(int j = i; j < temp_str.size(); j++){if(temp_str[j] == ']'){mouth.push_back(temp_str.substr(i + 1, j - i -1));//cout<<temp_str.substr(i + 1, j - i -1);i = j + 1;break;}}}else i++;}int k;scanf("%d", &k);for(int i = 0; i < k; i++){for(int j = 0; j < 5; j++) scanf("%d", &temp[j]);if(temp[0] > hands.size() || temp[1] > eyes.size() || temp[2] > mouth.size()||temp[3] > eyes.size()||temp[4] > hands.size()|| temp[0] < 1|| temp[1] < 1 || temp[2] < 1 || temp[3] < 1|| temp[4] < 1){printf("Are you kidding me? @\\/@\n");continue;}cout<<hands[temp[0] - 1]<< "(" <<eyes[temp[1] - 1]<<mouth[temp[2] - 1]<<eyes[temp[3] - 1] << ")" << hands[temp[4] - 1]<<endl;}}
