哪错了
查看原帖
哪错了
800408
yzh_yzh楼主2024/9/23 20:24
#include <bits/stdc++.h>
#define int unsigned long long int
using namespace std;
stack<int> sk;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr),cout.tie(nullptr);
	int T;
	cin>>T;
	while(T--){
		int n;
		cin>>n;
		while(n--){
			string s;
			cin>>s;
			int x;
			if(s=="push"){
				cin>>x;
				sk.push(x);
			}
			else if(s=="pop"){
				if(!sk.empty()){
					sk.pop();
				}else{
					puts("Empty");
				}
			}else if(s=="query"){
				if(!sk.empty()){
					cout<<sk.top()<<endl;
				}else{
					puts("Anguei!");
				}
			}else if(s=="size"){
				cout<<sk.size()<<endl;
			}
		}
	}
	return 0;
}
2024/9/23 20:24
加载中...