题解 | #【模板】队列#模仿AB1,请大家参阅
https://www.nowcoder.com/practice/afe812c80ad946f4b292a26dd13ba549
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; queue<int> q; string s; int t; for(int i = 0; i < n; i++){ cin >> s; if (s == "push") { cin >> t; q.push(t); } else if (s == "pop") { if(q.empty()){ cout << "error" << endl; }else{ cout << q.front() << endl; q.pop(); } } else if (s == "front") { if(q.empty()) { cout << "error" << endl; }else { cout << q.front() <<endl; q.front(); } } } return 0; }