#t1142. 数组逆序输出

数组逆序输出

Reverse Array Output

Problem Description

First lesson on arrays: store the data in an array, then walk through it backwards.

Read nn integers into an array, then output all of them in reverse order, starting from the last element. This problem drills accessing an array by index: indices start at 00, so the last element has index n−1n-1.

Input Format

The first line contains a positive integer nn; the second line contains nn integers separated by spaces.

Output Format

One line: the nn integers in the reverse order of the input, separated by spaces.

Sample Input

5
1 2 3 4 5

Sample Output

5 4 3 2 1

Constraints

For 100% of the test data, 1≤n≤10001 \le n \le 1000, and the absolute value of each element does not exceed 10910^9.

Hint: a reverse loop can be written as for (int i = n - 1; i >= 0; i--). You cannot print in reverse while reading number by number — all the data must be read before any output can start.