AC
#include"bits/stdc++.h"
using namespace std;
int main(){
int n,num;
cin>>n;
int ch;
int c=0;
queue<int> q;
for(int i=0;i<n;i++){
scanf("%d",&ch);
if(ch==1) {
scanf("%d",&num);
q.push(num);
c++;
}
else if(ch==2){
if(c==0){
cout<<"no"<<endl;
break;
}
else{
cout<<q.front()<<endl;
q.pop();
c--;
}
}
else{
cout<<c<<endl;
}
}
return 0;
}
- 输入
scanf("%d",&ch); if(ch==1) { scanf("%d",&num); q.push(num); c++; } el
- 特殊情况,遇到“no”,要退出(break)