0pts
查看原帖
0pts
793067
Sam_Gamer楼主2023/10/19 17:43
#include<iostream>
#include<queue>
#include<cstring>
#include<cstdio>
using namespace std;
inline int read()
{
	int x=0,p=1;
	char ch=getchar();
	while(ch=='-')
	{
		p=-1;
		ch=getchar();
	}
	while(ch>='0' && ch<='9')
	{
		x=x*10+(ch-'0');
		ch=getchar();
	}
	return x*p;
}
int main()
{
	queue<int>a;
	int n=read();
	for(int i=1;i<=n;i++)
	{
		int r;
		int q;
		r=read();
		if(r==1)
		{
			q=read();
			a.push(q);
		}
		if(r==2)
		{
			if(a.empty()) 
			{
				a.pop();
			}
			else
			{
				cout<<"ERR_CANNOT_POP\n";
			}
		}
		if(r==3)
		{
			if(a.empty())
			{
				cout<<a.front()<<'\n';
			}
			else
			{
				cout<<"ERR_CANNOT_QUERY\n";	
			}
		}
		if(r==4)
		{
			cout<<a.size()<<'\n';
		}
	}
	return 0;
}
2023/10/19 17:43
加载中...