33分,求delao调bug
查看原帖
33分,求delao调bug
922644
liumuxian楼主2024/1/14 16:59
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
stack<ll> q;
int main(){
	ios;
	ll t;
	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		for(ll i=1;i<=n;i++){
			string s;
			cin>>s;
			if(s=="push"){
				ll x;cin>>x;
				q.push(x);
			}
			if(s=="pop"){
				if(q.empty()) cout<<"Empty"<<endl;
				else q.pop();
			}
			if(s=="query"){
				if(q.empty()) cout<<"Anguei!"<<endl;
				else cout<<q.top()<<endl;
			}
			if(s=="size"){
				cout<<q.size()<<endl;
			}
		}
		while(!q.empty()) q.pop();		
	}
	return 0;
}
2024/1/14 16:59
加载中...