题解 | #Zero-complexity Transpo

Zero-complexity Transposition

https://www.nowcoder.com/practice/c54775799f634c72b447ef31eb36e975

//stack用法:逆序输出
#include <iostream>
#include <stack>
using namespace std;

stack<int> rev;
int main() {
    int n;
    while (cin >>n) { 
        for(int i=1;i<=n;i++)
        {
            int x;cin>>x;
            rev.push(x);
        }
        for(int i=1;i<=n;i++)
        {
            int x;
            x=rev.top();
            cout<<x<<" ";
            rev.pop();
        }        
    }
}

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务