66求助
查看原帖
66求助
443958
_Kirisame_Marisa_楼主2024/4/9 19:06
#include<iostream>
#include<stack>
#include<string>
using namespace std;
unsigned long long a,b;
unsigned long long x;
string str;
stack<unsigned long long>s;
int main(){
	cin>>a;
	for(unsigned long long i=1;i<=a;i++){
		cin>>b;
		for(unsigned long long j=1;j<=b;j++){
			cin>>str;
			if(str == "push"){
				cin>>x;
				s.push(x);
			}
			if(str == "query"){
				if(s.empty()){
					cout<<"Anguei!"<<endl;
				}else{
					cout<<s.top()<<endl;
				}
			}
			if(str == "pop"){
				if(s.empty()){
					cout<<"Empty"<<endl;
				}else{
					s.pop();
				}
			}
			if(str == "size"){
				x=s.size();
				cout<<x<<endl;
			}
		}
	}
	return 0;
} 
2024/4/9 19:06
加载中...