zl程序教程

您现在的位置是:首页 >  其它

当前栏目

【PAT乙级】1052 卖个萌 (20 分)

20 PAT 乙级
2023-09-11 14:15:52 时间

在这里插入图片描述
题目地址

#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
string s; 
vector<string> ve[5];
int main(void)
{
	for(int i=0;i<3;i++)
	{
		getline(cin,s); 
		while(s.size())
		{
			int l=s.find('[');
			int r=s.find(']');
             if(r==-1) break;
			ve[i].push_back(s.substr(l+1,r-l-1));
			s=s.substr(r+1);
		}
	}
	ve[3]=ve[1],ve[4]=ve[0];
	int k;cin>>k;
	for(int i=0;i<k;i++) 
	{
		string temp;
		bool flag=true;
		for(int j=0;j<5;j++)
		{
			int x; cin>>x;
			if(j==1) temp+="(";
			if(x>ve[j].size()||x<=0) flag=false;
			else temp+=ve[j][x-1];
			if(j==3) temp+=")";
		}
		if(flag) cout<<temp;
		else cout<<"Are you kidding me? @\\/@";
        cout<<endl;
	}
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
vector<string>ve[3];
int main(void)
{
	for(int i=0;i<3;i++)
	{
		string s; getline(cin,s);
		for(int j=0;j<s.size();j++)
		{
			if(s[j]=='[')
			{
				j++;
				string temp;
				while(s[j]!=']') temp+=s[j],j++;
				ve[i].push_back(temp);
			}
		}
	}
	int n; cin>>n;
	while(n--)
	{
		int a1,b1,c,b2,a2; cin>>a1>>b1>>c>>b2>>a2;
        a1--,b1--,c--,b2--,a2--;
		if(a1<ve[0].size()&&a2<ve[0].size()&&b1<ve[1].size()&&b2<ve[1].size()&&c<ve[2].size())
			printf("%s(%s%s%s)%s\n",ve[0][a1].c_str(),ve[1][b1].c_str(),ve[2][c].c_str(),ve[1][b2].c_str(),ve[0][a2].c_str());
		else puts("Are you kidding me? @\\/@");
	}
	return 0;
}