这是我们老师讲的标准答案,直接抄!!!!
#include<bits/stdc++.h>
#include<queue>
using namespace std;
queue<int> q;
/*入队:
for(int i=1;i<=?;i++){
q.push(i);
}
队首元素:cout << q.front() << " ";
队尾元素:cout << q.back() << " ";
队列大小:cout << q.size() << " ";
遍历队列:
while(!q.empty()){
cout << q.front() << " ";//输出对首
q.pop();//队首滚开(出队)
}
*/
int main(){
int n,a[10005],b;
cin >> n;
for(int i=1;i<=n;i++){
cin >> a[i];
if(a[i] == 2){
if(q.empty()){
cout << "impossible!" << endl;
}
else{
q.pop();
}
}
if(a[i] == 1){
cin >> b;
q.push(b);
}
if(a[i] == 3){
if(q.empty()){
cout << "impossible!" << endl;
}
else{
cout << q.front() << endl;
}
}
}
return 0;
}