救命 为什么一直调不好
查看原帖
救命 为什么一直调不好
1175242
Zxx20120715楼主2024/6/18 19:59
#include<bits/stdc++.h>
#include<stack>
using namespace std;
stack<unsigned long long> st;
unsigned long long x;
int main(){
	unsigned long long t,n;
	cin>>t>>n;
	string s;
	for(int i=1;i<=t;i++){
		for(int j=1;j<=n;j++){
			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;
}

一开始用数组来模拟栈,结果不对。

然后我又用的栈,得了 3333 分(#2 AC),不知道哪里错了。

此蒟蒻五年级,请求大佬相助 QWQ。

2024/6/18 19:59
加载中...