33pts HELP!!!!!!!! 求调!!!!!!
查看原帖
33pts HELP!!!!!!!! 求调!!!!!!
777500
Tang15387021810楼主2024/12/15 14:43

原题传送门

#include<iostream>
#include<cstdio>
#include<stack>
#include<string>
using namespace std;
long long t,n,x;
string s1;
stack<unsigned long long int> s;
int main()
{
	cin>>t;
	for(int i=1;i<=t;i++)
	{
		cin>>n;
		for(int j=1;j<=n;j++)
		{
			cin>>s1;
			if(s1=="push")
			{
				cin>>x;
				s.push(x);	
			}
			if(s1=="pop")
			{
				if(!s.empty())	s.pop();
				else			cout<<"Empty"<<endl;
			}
			if(s1=="query")
			{
				if(!s.empty())	cout<<s.top()<<endl;					
				else			cout<<"Anguei!"<<endl;
			}
			if(s1=="size")	cout<<s.size()<<endl;
		}
	}
	while(!s.empty())	s.pop();
	return 0;
}

2024/12/15 14:43
加载中...