c++现成的stl不用白不用,不会真的有人自己写一遍栈的数据结构吧(
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,k;
cin>>n;
stack<int> s1;
    for(int i=1;i<=n;i++){
        cin>>m;
        for(int j=1;j<=m;j++){
            cin>>k;
            s1.push(k);
        }
        for(int j=1;j<=m;j++){
            cout<<s1.top()<<" ";
            s1.pop();
        }
        cout<<endl;
    }
}