phi_gros @ 2024-10-28 20:32:20
#include<bits/stdc++.h>
using namespace std;
int main(){
stack <unsigned long long> s;
int t;
cin >> t;
while(t --){
int n;
cin >> n;
for(int i = 1;i <= n;i ++){
string a;
unsigned long long b;
cin >> a;
if(a == "push"){
cin >> b;
s.push(b);
}
else if(a == "pop"){
if(s.empty())
cout << "Empty\n";
else s.pop();
}
else if(a == "size"){
cout << s.size() << "\n";
}
else{
if(s.size())
cout << s.top();
else cout << "Anguei!";
cout << "\n";
}
}
}
return 0;
}
呜呜呜,为什么66分,调试好多遍了
by Civilight_Eterna @ 2024-10-28 20:45:13
@phi_gros 你没清空栈
by Reduct @ 2024-10-28 20:56:40
while(!s.empty())s.pop
记得清空
by phi_gros @ 2024-10-28 21:12:57
@xionghaoran123 感谢
by phi_gros @ 2024-10-28 21:13:18
@Reduct 谢谢大佬
by phi_gros @ 2024-10-28 21:16:05
@xionghaoran123 @Reduct 已过,感谢