生活随笔
收集整理的這篇文章主要介紹了
【PAT乙级】1052 卖个萌 (20 分)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目地址
#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;
}
總結
以上是生活随笔為你收集整理的【PAT乙级】1052 卖个萌 (20 分)的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。