#C13213. Special Odd Sorting
Special Odd Sorting
Special Odd Sorting
You are given a list of integers. The task is to sort only the odd numbers in non-decreasing order while keeping the even numbers at their original positions. Formally, let \( A = [a_1, a_2, \ldots, a_n] \). Define the set of odd elements as \( O = \{a_i \mid a_i \bmod 2 \neq 0\} \). When sorted, these odd numbers become \( O' \) such that \( O' = \text{sorted}(O) \). Replace the odd numbers in the original list with the values from \( O' \) in order, while leaving the even numbers unchanged.
Example: For the list [5, 3, 2, 8, 1, 4], the odd numbers are [5, 3, 1]. After sorting, they become [1, 3, 5]. Inserting them back into their positions results in [1, 3, 2, 8, 5, 4].
inputFormat
The input is read from standard input (stdin) and consists of two lines. The first line contains a single integer \( n \) denoting the number of elements in the list. The second line contains \( n \) space-separated integers representing the list.
Example:
6 5 3 2 8 1 4
outputFormat
The output should be printed to standard output (stdout) as a single line with the transformed list of integers separated by spaces.
Example:
1 3 2 8 5 4## sample
6
5 3 2 8 1 4
1 3 2 8 5 4