0分!求助!!!
查看原帖
0分!求助!!!
1350521
SimonLan楼主2024/8/29 11:58
#include<bits/stdc++.h>
using namespace std;
unsigned long long n,m;
stack<int> s;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>m;
		for(int j=1;j<=m;j++){
			string h;
			cin>>h;
			if(h=="push"){
				unsigned int x;
				cin>>x;
				s.push(x);
			}
			else if(h=="query"){
				if(s.empty()){
				   cout<<"Anguei!";
				}
				else cout<<s.top();
			}
			if(h=="size"){
				cout<<s.size();
			}
			if(h=="pop"){
				if(s.empty()){
					cout<<"Empty";
				}
				else s.pop(); 
			}
		}
	}
}

2024/8/29 11:58
加载中...