#46312: 用stack的解法


resol4471 (ResoL)

學校 : 臺北市立建國高級中學
編號 : 238959
來源 : [140.116.118.29]
最後登入時間 :
2025-04-15 00:15:29

#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;
}