0tps求助
查看原帖
0tps求助
1012241
Dcchen楼主2023/11/5 18:02
#include<iostream>
#include<iomanip>
#include<queue>
using namespace std;
int T,x,n;
queue<int>pq;
int main(){
	cin>>T;
	while(T--){
		cin>>x;
		if(x==1) cin>>n,pq.push(n);
		else if(x==2){
			if (pq.size()==0) cout << "ERR_CANNOT_POP\n";
            else pq.pop();
		}
		else if(x==3){
			//cout<<"cout<<   ";
			if (pq.empty()) cout << "ERR_CANNOT_POP\n";
            else cout<<pq.front()<<endl;
		}
		else{
			//cout<<"cout<<   ";
			int a=pq.size();
			if(a>=0) cout<<a<<endl;
			else cout<<"ERR_CANNOT_QUERY\n";
		}
	}
	return 0;
}
2023/11/5 18:02
加载中...