求助!
查看原帖
求助!
1312338
0000aaaa楼主2024/7/2 13:00

为什么我能过样例但过不了这道题

#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long t;
	cin>>t;
	while(t--)
	{
		stack<long long> a;
		string s;
		long long n,x;
		cin>>n;
		while(n--);
		{
			cin>>s;
			if(s=="push")
			{
				cin>>x;
				a.push(x);
			}
			if(s=="pop")
				if(a.size()!=0) a.pop();
				else cout<<"Empty"<<endl;
			if(s=="query")
				if(a.size()!=0) cout<<a.top()<<endl;
				else cout<<"Anguei!"<<endl;
			if(s=="size")
				cout<<a.size()<<endl;
		}
	}
	return 0;
}
2024/7/2 13:00
加载中...