#C12257. Reorder Array
Reorder Array
Reorder Array
You are given a list of integers. Your task is to reorder the list so that all even numbers appear in ascending order followed by all odd numbers in descending order.
If any element in the input is not an integer, you must print the exact error message: \(\text{Input list must contain only integer values}\) and terminate the program.
Input/Output Specifications: The input is read from standard input (stdin) and the output must be printed to standard output (stdout). The first line of the input contains a single integer \(n\) representing the number of elements in the list. If \(n > 0\), the second line will contain \(n\) space-separated tokens. If \(n = 0\), the list is empty and you should print nothing.
inputFormat
The input from stdin consists of 2 parts:
- The first line contains an integer \(n\), the number of elements in the list.
- If \(n > 0\), the second line contains \(n\) space-separated tokens representing the elements.
Note: The tokens must represent valid integers. Otherwise, print the error message.
outputFormat
The output should be a single line printed to stdout. It contains the reordered list with even numbers in ascending order followed by odd numbers in descending order, with each number separated by a single space.
If the list is empty (i.e., \(n = 0\)), print nothing. In case of invalid input (non-integer values), print: \(\text{Input list must contain only integer values}\).
## sample0