33分,请求大佬帮帮我
查看原帖
33分,请求大佬帮帮我
1273263
chenhouye楼主2024/10/2 13:15
#include<bits/stdc++.h>
using namespace std;
stack<unsigned long long>st;
int n,t;
unsigned long long x;
string s;
int main(){
	scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		for(int i=1;i<=n;i++){
			cin>>s;
			if(s=="push"){
				scanf("%lld",&x);
				st.push(x);
			}
			else if(s=="query"){
				if(st.empty()) printf("Anguei!\n");
				else printf("%lld\n",st.top());
			}
			else if(s=="pop"){
				if(st.empty()) printf("Empty\n");
				else st.pop();
			}
			else printf("%d\n",st.size());
		}
	}
	return 0;
}

谢谢

2024/10/2 13:15
加载中...