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