Lv.1
WHATTTOTTT240234002304032 Sir,are you 🆗?
签名:Prob=3.0?!
在 【社区星推荐】第六期·小企鹅飞 中回复
PraB(#>&&)${12345????}https://ide.codemao.cn/#37900278
https://shequ.codemao.cn/work/37900278
#include<bits/stdc++.h>
using namespace std;
int m,n,num,qui=1,quj=1,wer[10001],a;
string x;
int main() {
cin>>m;
for(int i=1; i<=m; i++) {
queue<int>q;
stack<int>s;
cin>>n;
a=0,qui=1,quj=1;
for(int j=1; j<=n; j++) {
cin>>x;
if(x=="push") {
cin>>num;
q.push(num);
s.push(num);
} else if(x=="pop"){
if(q.empty())qui=0;
else {
q.pop();
}
if(s.empty())quj=0;
else {
s.pop();
}
}
}
if(qui==0)cout<<"error";
else {
while(!q.empty()) {
cout<<q.front();
q.pop();
if(!q.empty())cout<<" ";
}
}
cout<<"\n";
if(quj==0)cout<<"error";
else {
while(!s.empty()) {
wer[++a]=s.top();
s.pop();
}
while(a!=0) {
cout<<wer[a];
a-=1;
if(a!=0)cout<<" ";
}
}
cout<<"\n";
}
return 0;
}
2020-01-13T16:46:57 点赞:0