红
查看原帖
红
1044461
liguanda楼主2024/4/14 16:21
#include <bits/stdc++.h>
using namespace std;
int a[10005],x,b=1,c=1,n;//b队尾指针,c队首指针 
int main(){
	cin >> n;
	for (int i  = 1; i <= n; i++){
		cin >> x;
		if (x==1){
			cin >> a[b];
			++b;
		} else if (x==2){
			++c; 
		} else if (x==3){
			if (c==b){
				cout << "ERR_CANNOT_POP" << endl;
			} else
			cout << a[c] << endl;
		} else {
			if (c==b){
				cout <<"ERR_CANNOT_QUERY" << endl;
			} else
			cout << b-c << endl; 
		}
	}
	return 0;
}
2024/4/14 16:21
加载中...