题解
2026-08-11 16:34:47
发布于:浙江
0阅读
0回复
0点赞
这道题是明显的后进先出 (LIFO) 可以用STL模板中的栈解决。
代码如下:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
stack<int>s;
while(n--){
int a;
cin>>a;
s.push(a);
}
while(!s.empty()){
cout<<s.top()<<"\n";
s.pop();
}
}
这里空空如也





有帮助,赞一个