差最后一个点
查看原帖
差最后一个点
1267585
zhouyoujia2024楼主2024/12/29 15:59
#include<bits/stdc++.h>
using namespace std;
int main() {
	unsigned long long T,n,num;
	string str;
	stack<unsigned long long> s;
	cin>>T;
	while(T--){
		cin>>n;
		for(int i=1;i<=n;i++) {
			cin>>str;
			if(str=="push") {
				cin>>num;
				s.push(num);
			}
			else if(str=="query") {
				if(!s.empty()) cout<<s.top()<<endl;
				else cout<<"Anguei!"<<endl;
			}
			else if(str=="pop") {
				if(!s.empty()) s.pop();
				else cout<<"Empty"<<endl;
			}
			else cout<<s.size()<<endl;
		}
	}
	return 0;
}
2024/12/29 15:59
加载中...