#66分 QWQ
查看原帖
#66分 QWQ
931492
xiaohuanxiong楼主2023/9/10 20:18
#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
const ll N=1e7;
ll s[N],t,n,m,top=0;
string q;
void push()
{
	cin>>m;
	top++;
	s[top]=m;
}
void pop()
{
	if (top==0)
	{
		cout<<"Empty"<<endl;
		return;
	}
	s[top]=0;
	top--;
}
void query()
{
	if (top==0)
	{
		cout<<"Anguei!"<<endl;
		return;
	}
	cout<<s[top]<<endl;
}
void size()
{
	cout<<top<<endl;
}
int main()
{
	cin>>t;
	while (t--)
	{
		cin>>n;
		for (long long i=1;i<=n;i++)
		{
			cin>>q;
			if (q=="push")
				push();
			if (q=="pop")
				pop();
			if (q=="query")
				query();
			if (q=="size")
				size();
		}
	}
	return 0;

2023/9/10 20:18
加载中...