66分求调
查看原帖
66分求调
1050581
chen__pengyu楼主2024/9/16 17:19

各位大佬帮忙揪揪错

#include<bits/stdc++.h>
using namespace std;
stack<unsigned long long >st;
unsigned long long t,n;
int main() {
	cin>>t;
	for(int i=1; i<=t; i++) {
		cin>>n;
		for(int j=1; j<=n; j++) {
			string s;
			unsigned long long x;
			cin>>s;
			if(s=="push") {
				cin>>x;
				st.push(x);
			} else if(s=="query") {
				if(st.empty()) {
					cout<<"Anguei!"<<endl;
				} else {
					cout<<st.top()<<endl;
				}
			} else if(s=="pop") {
				if(st.empty()) {
					cout<<"Empty"<<endl;
				} else {
					st.pop();
				}
			}else if(s=="size"){
				cout<<st.size()<<endl;
			}
		}
	}
	return 0;
}
2024/9/16 17:19
加载中...