0分……
查看原帖
0分……
379114
Kerman0411楼主2022/9/19 17:45
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		stack<long long> s;
		int n;
		scanf("%d",&n);
		while(n--){
			string opr;
			long long x;
			cin>>opr;
			if(opr=="push"){
				scanf("%lld",&x);
				s.push(x);
			}else if(opr=="pop"){
				if(s.empty()){
					printf("Empty\n");
				}else{
					s.pop();
				}
			}else if(opr=="query"){
				if(s.empty()){
					printf("Anguei!\n");
				}else{
					printf("%lld\n",s.top());
				}
			}else{
				printf("%d\n",s.size());
			}
		}
	}
	return 0;
}
2022/9/19 17:45
加载中...