蒟蒻33分求助!!QAQ
查看原帖
蒟蒻33分求助!!QAQ
1000377
Chun_My楼主2023/8/13 09:28
#include <iostream>//坚持不用万能头的第一百一十二天 
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <stack>
using namespace std;
string order;
long long x;
stack<unsigned long long>m;
int main(){
	long long n;
	cin>>n;
	long long a;
	
	for(int i=1;i<=n;i++){
		cin>>a;
		for(int j=1;j<=a;j++){
			cin>>order;
			if(order=="push"){
				cin>>x;
				m.push(x);
			}
			if(order=="pop"){
				if(m.empty()==1){
					cout<<"Empty"<<endl;
				}
				else{
					m.pop();
				}
			}
			if(order=="query"){
				if(m.empty()==1){
					cout<<"Anguei!"<<endl;
				}
				else{
					cout<<m.top()<<endl;
				}
			}
			if(order=="size"){
				cout<<m.size()<<endl;
			}
		}
	}
}
2023/8/13 09:28
加载中...