So easy
2026-02-07 14:52:38
发布于:浙江
2阅读
0回复
0点赞
因为stack不支持下标,所以先要stack首输出,然后删除
#include<iostream>
#include<stack>
using namespace std;
stack<int> q;
int main(){
int n,x;
cin>>n;
for(int i=0;i<n;i++){
cin>>x;
q.push(x);
}
for(int i=0;i<n;i++){
cout<<q.top()<<" ";
q.pop();
}
}
这里空空如也







有帮助,赞一个