向大佬求调QAQ
查看原帖
向大佬求调QAQ
478697
xuanye楼主2022/6/17 22:30
#include<bits/stdc++.h>
using namespace std;
int t,n;
string s;
stack<unsigned long long> st;
int main(){
	cin>>t;
	for(int i=1;i<=t;i++){
		cin>>n;
		for(int j=1;j<=n;j++){
			cin>>s;
			if(s=="push"){
				unsigned long long a;
				cin>>a;
				st.push(a);
			}
			if(s=="pop"){
				if(!st.empty()){
					st.pop();
				}
				else{
					cout<<"Empty"<<endl;
				}
			}
			if(s=="query"){
				if(!st.empty()){
					cout<<st.top();
				}
				else{
					cout<<"Anguei!"<<endl;
				}
			}
			if(s=="size"){
				cout<<st.size()<<endl;
			}
		}
		while(!st.empty()){
			st.pop();
		}
	}
	
	return 0;
}

2022/6/17 22:30
加载中...