【算法代码】
#include <bits/stdc++.h>
using namespace std;
int n,x;
int main() {
cin>>n;
stack<int> s;
while(n--) {
cin>>x;
s.push(x);
}
while(!s.empty()) {
cout<<s.top()<<" ";
s.pop();
}
return 0;
}
/*
in:
7
12 6 8 5 27 9 3
out:
3 9 27 5 8 6 12
*/