题解 | #Zero-complexity Transposition#

Zero-complexity Transposition

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

/*
描述
You are given a sequence of integer numbers. Zero-complexity transposition of the sequence is the reverse of this sequence. Your task is to write a program that prints zero-complexity transposition of the given sequence.
输入描述:
For each case, the first line of the input file contains one integer n-length of the sequence (0 < n ≤ 10 000). The second line contains n integers numbers-a1, a2, …, an (-1 000 000 000 000 000 ≤ ai ≤ 1 000 000 000 000 000).
输出描述:
For each case, on the first line of the output file print the sequence in the reverse order.
*/

#include<iostream>
#include<stack>

using namespace std;


int main() {
    int n,tmp;
    stack<int> arr;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> tmp;
        arr.push(tmp);
    }
    while (!arr.empty())
    {
        cout << arr.top() << " ";
        arr.pop();
    }
    return 0;
}
全部评论

相关推荐

搞机墨镜猫:科研和竞赛全写成项目经历,另外你项目涉及到的技术栈太杂了,应该对不同岗位强调写不同的技术栈,寒假应该不太好找短期,长期明年3,4月好找很多
点赞 评论 收藏
分享
头像
2025-12-27 13:01
三峡大学 C++
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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