KY109 Zero-complexity TranspositionC++

llllmz / 2024-01-18 / 原文

h

很简单的题目,不管是用数组还是用栈都非常简单。

#include<iostream>
#include<stack>
using namespace std;
int main(){
    int n;
    while(cin >> n){
        stack<long> s;
        while(n!=0){
            int tem;
            cin >> tem;
            s.push(tem);
            n--;
        }
        while(!s.empty()){
            int x=s.top();
            cout << x <<' ';
            s.pop();
        }
    }
    return 0;
}

结果: