题解 | #【模板】队列#
【模板】队列
https://www.nowcoder.com/practice/afe812c80ad946f4b292a26dd13ba549
#include <iostream>
#include <queue>
using namespace std;
int main() {
int n;
cin >> n;
queue<int> que;
string s;
int num;
for (int i = 0; i < n; i++) {
cin >> s;
if (s == "push") {
cin >> num;
que.push(num);
}
if (s == "pop") {
if (que.empty())
cout << "error" << endl;
else {
cout << que.front() << endl;
que.pop();
}
}
if (s == "front") {
if (que.empty())
cout << "error" << endl;
else
cout << que.front() << endl;
}
}
return 0;
}
