【PTA/乙级】【1052】 卖个萌 (20 分)
作者:互联网
字符串处理以及t居然有可能小于1(测试点2);
Are you kidding me? @\/@
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main()
{
vector<vector<string> >bub;
for (int k = 0; k < 3; k++)
{
string s;
getline(cin, s);
vector<string>v;
for (int i = 0; s[i]; i++)
{
if (s[i] == '[') {
for (int j = i; s[j]; j++) {
if (s[j] == ']') {
v.push_back(s.substr(i + 1, j - i - 1));
i = j;
break;
}
}
}
}
bub.push_back(v);
}
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
int t;
string s;
bool flag = 0;
for (int j = 0; j < 3; j++) {
cin >> t;
if (bub[j].size() >= t && t > 0) {//越界检查
s += bub[j][--t];
if (j == 0) s += "(";
}
else
flag = 1;
}
for (int j = 1; j >= 0; j--) {
cin >> t;
if (bub[j].size() >= t && t > 0) {//越界检查
s += bub[j][--t];
if (j == 1) s += ")";
}
else
flag = 1;
}
if (flag)
cout << "Are you kidding me? @\\/@\n";
else
cout << s << endl;
}
return 0;
}
标签:1052,20,int,cin,PTA,++,flag,bub,include 来源: https://blog.csdn.net/qq_55799677/article/details/120869898