#t1142. 数组逆序输出
数组逆序输出
Reverse Array Output
Problem Description
First lesson on arrays: store the data in an array, then walk through it backwards.
Read 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 , so the last element has index .
Input Format
The first line contains a positive integer ; the second line contains integers separated by spaces.
Output Format
One line: the 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, , and the absolute value of each element does not exceed .
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.