20求助
查看原帖
20求助
980732
Main_Void_楼主2023/8/10 17:01
#include<iostream>
using namespace std;
typedef unsigned long long ull;
const ull N = 1e8; 
ull que[N], hh = 0, tt = -1;
void push(ull x)
{
	que[++tt] = x;
}
void pop()
{
	if (hh > tt)
		cout << "ERR_CANNOT_POP" << endl;
	else
		hh++;
}
void query()
{
	if (hh > tt)
		cout << "ERR_CANNOT_QUERY" << endl;
	else
		cout << que[hh] << endl; 
}
void size()
{
	cout << tt - hh + 1 << endl;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ull n;
	cin >> n;
	while(n--)
	{
		int k; 
		cin >> k;
		if (k == 1)
		{
			ull x;
			cin >> x;
			push(x);
		}
		else if (k == 2)
		{
			pop();
		}
		else if (k == 3)
		{
			query();
		}
		else
			size();
	}
}
2023/8/10 17:01
加载中...