为什么我的代码连样例都过不了???
查看原帖
为什么我的代码连样例都过不了???
785767
44i11楼主2023/8/5 16:12
#include<bits/stdc++.h>
using namespace std;
int t;
int main(){
	cin>>t;
	while(t--){
		stack<unsigned long long>s;
		int n;
		cin>>n;
		while(n--){
			string str;
			cin>>str;
			if(str=="push"){
				unsigned long long x;
				cin>>x;
				s.push(x);
			}else if(str=="pop"){
				if(s.empty()){
					cout<<"Empty"<<endl;
				}else{
					s.pop();
				}
			}else if(str=="query"){
				if(s.empty()){
					cout<<"Anguei!"<<endl;
				}else{
					cout<<s.top()<<endl;
				}
				cout<<s.top()<<endl;
			}else if(str=="size"){
				cout<<s.size()<<endl;
			}
		}
	}
}
2023/8/5 16:12
加载中...