1222
查看原帖
1222
766647
_Chjich_楼主2023/10/10 15:53
#include <bits/stdc++.h>
using namespace std;
int n, x, sd;
queue <int> q;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x;
		if (x == 1) {
			cin >> sd ;
			q.push(sd);
		} else if (x == 2) {
			if (q.front() == 0) {
				cout << "ERR_CANNOT_POP" << endl;
				break;
			} else {
				cout << q.front() << endl;
				q.pop() ;
			}
		} else if (x == 3) {
			if (q.front() == 0) {
				cout << "ERR_CANNOT_QUERY" << endl;
				break;
			} else {
				cout << q.front() << endl ;
			}

		} else if (x == 4) {
			cout << q.size() ;
		}
	}
	return 0;
}
2023/10/10 15:53
加载中...