题解 | #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;
}
查看8道真题和解析