求大佬调
查看原帖
求大佬调
550898
xjx199楼主2023/11/29 23:06
#include<bits/stdc++.h>
using namespace std;
stack<int>s;
int main()
{
	string a;
	long long n,k,x;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>k;
		for(int j=0;j<k;j++)
		{
			cin>>a;
			if(a=="push")
			{
				cin>>x;
				s.push(x);
				cout<<x<<endl;
			}
			if(a=="query")
			{
				if(s.empty()) cout<<"Anguei!"<<endl;
				else
				{
					cout<<s.top()<<endl;
				}
			}
			if(a=="pop")
			{
				if(s.empty()) cout<<"Empty"<<endl;
				else
				{
					s.pop();
				}
			}
			if(a=="size")
			{
				cout<<s.size()<<endl;
			}
		}
	}
	return 0;
}
2023/11/29 23:06
加载中...