题解 | 【模板】队列操作
【模板】队列操作
https://www.nowcoder.com/practice/1137c8f6ffac4d5d94cc1b0cb08723f9
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;
queue<int> q;
while(n--){
int a; cin >> a;
if(a == 1){
int x; cin >> x;
q.push(x);
}
if(a == 2){
if(!q.empty())
q.pop();
else
cout << "ERR_CANNOT_POP" << endl;
}
if(a == 3){
if(!q.empty())
cout << q.front() << endl;
else
cout << "ERR_CANNOT_QUERY" << endl;
}
if(a == 4){
cout << q.size() << endl;
}
}
return 0;
}

