#C14597. Reverse the List

    ID: 44263 Type: Default 1000ms 256MiB

Reverse the List

Reverse the List

The task is to reverse the order of integers in a given list. You are provided with a list of integers and your goal is to output the list in reverse order without using any built-in reverse functions or methods.

For example, given the list \( [1,2,3,4,5] \), the output should be \( [5,4,3,2,1] \). Use a simple loop to iterate through the list in reverse order and construct the new list.

inputFormat

The first line of input contains a single integer ( n ) representing the number of elements in the list. The second line contains ( n ) space-separated integers.

outputFormat

Output the integers of the reversed list in one line separated by a single space. If the list is empty (i.e., when ( n = 0 )), output nothing.## sample

5
1 2 3 4 5
5 4 3 2 1