蒟蒻求助
查看原帖
蒟蒻求助
991923
XZQ065楼主2023/7/18 11:33
#include<bits/stdc++.h>
using namespace std;
queue<int> q;
int n,t,x;
int main(){
	cin>>n;
	while(n--){
		cin>>t;
		if(t==1){
			cin>>x;
			q.push(x);
		}
		else if(t==2){
			if(!q.empty()){
				q.pop();
			}
			else{
				cout<<"ERR_CANNOT_POP";
			}
		}
		else if(t==3){
			if(!q.empty()){
				cout<<q.front()<<endl;
			}
			else{
				cout<<"ERR_CANNOT_QUERY";
			}
		}
		else{
			cout<<q.size()<<endl;
		}
	}
	return 0;
}
2023/7/18 11:33
加载中...