#K14746. Reverse Even Numbers
Reverse Even Numbers
Reverse Even Numbers
You are given a list of integers. Your task is to output a new list that contains only the even numbers from the input list, but in reverse order.
An integer n is considered even if it satisfies the condition \( n \mod 2 = 0 \).
For example, given the input list 1 2 3 4 5 6
, the even numbers are 2, 4, 6
and after reversing the order the output should be 6 4 2
.
inputFormat
The input is provided via standard input (stdin) in the following format:
- The first line contains a single integer \( n \) representing the number of elements in the list (\( 0 \le n \le 10^5 \)).
- The second line contains \( n \) space-separated integers.
outputFormat
Print a single line containing the even numbers from the input list in reverse order, separated by a single space. If there are no even numbers, output an empty line.
## sample6
1 2 3 4 5 6
6 4 2
</p>