#include <iostream> #include <cstdio> #include <string> #include <algorithm> #include <stack> using namespace std; /** * Zero-complexity Transposition--上海交通大学 * @return */ int main() { int n; while (cin >> n) { long long num; stack<long long> stack; for (int i = 0; i < n; ++i) { cin >> num; stack.push(num); } //循环取栈顶元素,即可完成逆序输出 while (!stack.empty()) { if (stack.size() == 1) { //最后一个数字换行 cout << stack.top() << endl; } else { //非最后一个输出空格 cout << stack.top() << " "; } stack.pop(); } } return 0; }