33分求助
查看原帖
33分求助
1093556
serendipity_moet楼主2024/10/16 19:05

我真的不知道为什么33分了?求助各位大神!!!

#include<bits/stdc++.h>
using namespace std;
std::stack<unsigned long long> m;
int unsigned long long T,n,x;
string b;
void push(int l)
{
	m.push(l);
}
void pop()
{
	if(m.empty())
	{
		cout<<"Empty"<<endl;
		return;
	}
	m.pop();
}
void query()
{
	if(m.empty())
	{
		cout<<"Anguei!"<<endl;
		return;
	}
	cout<<m.top()<<endl;
}
void size()
{
	cout<<m.size()<<endl;
}
int main()
{
	cin>>T;
	for(int i=1;i<=T;i++)
	{
		cin>>n;		
		for(int j=1;j<=n;j++)
		{
			cin>>b;
			if(b=="push")
			{
				cin>>x;
				push(x);		
			}
			if(b=="query")
			{
				query();
			}
			if(b=="pop")
			{
				pop();		
			}
			if(b=="size")
			{
				size();		
			}
		}
	}
}
2024/10/16 19:05
加载中...