#46312: 用stack的解法


resol4471 (ResoL)


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int, int>
#define vll vector<long long int>

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
   

    int n,x;
    stack<int> st;

    cin >> n;
    for (int i=0; i<n;i++){
        cin >> x;
        st.push(x);
    }

    while(!st.empty()){
        cout << st.top() << " ";
        st.pop();
    }
    return 0;
}