题解 | #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;
}
全部评论

相关推荐

点赞 评论 收藏
分享
11-04 14:10
东南大学 Java
_可乐多加冰_:去市公司包卖卡的
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务