66求调
查看原帖
66求调
874932
Niko840楼主2024/11/21 13:07
#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
ll n,m,x;
string s;
stack<ll>a;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>m;
		for(int j=1;j<=m;j++)
		{
			cin>>s;
			if(s=="push")
			{
				cin>>x;
				a.push(x);
				x=0;
			}
			else if(s=="pop")
			{
				if(a.size())
					a.pop();
				else
					cout<<"Empty\n";
			}
			else if(s=="query")
			{
				if(a.size())
					cout<<a.top()<<"\n";
				else
					cout<<"Anguei!\n";
			}
			else if(s=="size")
			{
				cout<<a.size()<<"\n";
			}
		}
	}
	
	return 0;
}

2024/11/21 13:07
加载中...