0分求调
查看原帖
0分求调
512587
Konnyaku_q楼主2024/9/10 21:09
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cmath>
#include<queue>
#include<algorithm>
#include<vector>
using namespace std;
long long t,n,top=0,zhan[1100000],a;
string s;
int main()
{
	cin>>t;
	for(int i=1;i<=t;i++)
	{
	
		cin>>n; 
		for(int j=1;j<=n;j++)
		{
			cin>>s;
			if(s=="push")
			{
				cin>>a;
				zhan[top++]=a;
			}
			else if(s=="pop")
			{
				if(top==0)
				{
					cout<<"Empty"<<endl;	
				}
				else
				{
					top--;
				}
			 } 
			 else if(s=="query")
			 {
			 	if(top==0)
			 	{
			 		cout<<"Anguei!"<<endl;
				 }
				 else
				 {
				 	cout<<zhan[top]<<endl;
				 }
			 }
			 else if(s=="size")
			 {
			 	cout<<top<<endl;
			 }
		  }
		  top=0; 
		}
	   
	    
  return 0;
}

2024/9/10 21:09
加载中...