#P1427. Reverse the Number Sequence
Reverse the Number Sequence
Reverse the Number Sequence
Little fish has been tasked to participate in a numerical game. He is presented with a sequence of integers ai that ends with a 0. The terminal 0 is only the marker for the end of the input and should not be included in the output. Your task is to help little fish by reversing the order of the numbers before the 0.
Note: Input will consist of numbers separated by spaces or newlines, and the sequence always ends with a 0 which should not be printed.
inputFormat
The input consists of a series of integers separated by spaces or newlines. The sequence is terminated by a single 0, which is not part of the sequence to be reversed.
outputFormat
Output the reversed sequence of numbers (excluding the terminating 0), with each number separated by a single space.
sample
1 2 3 0
3 2 1