30pts 求调
查看原帖
30pts 求调
1259734
shenxiangxin楼主2025/8/4 22:32
#include<bits/stdc++.h>
using namespace std;
int t,n;
stack<long long>s;
int main()
{
	cin>>t;
	while(t--)
	{
		cin>>n;
		while(n--)
		{
			string a;
			cin>>a;
			
			if(a=="push")
			{
				long long x;
				cin>>x;
				s.push(x);
			}
			else if(a=="pop")
			{
				if(!s.empty())
				{
					s.pop();
				}
				else
				{
					cout<<"Empty"<<endl;
				}
			}
			else if(a=="query")
			{
				if(!s.empty())
				{
					long long x=s.top();
					cout<<x<<endl;
				}
				else
				{
					cout<<"Anguei!"<<endl;
				}
			}
			else
			{
				cout<<s.size()<<endl;
			}
		}
		
	}
 } 
2025/8/4 22:32
加载中...