#K38067. Sort Odd Numbers
Sort Odd Numbers
Sort Odd Numbers
Given an array of integers, your task is to sort only the odd numbers in ascending order while keeping the even numbers at their original positions. In other words, if an integer \(a_i\) in the array is odd (i.e. \(a_i \mod 2 \neq 0\)), then it should be re-arranged in ascending order. The even numbers must remain in their original positions.
Example: For the input array [4, 3, 2, 1, 5], the output must be [4, 1, 2, 3, 5] because only the odd numbers (3, 1, 5) are sorted to become (1, 3, 5).
inputFormat
The first line contains an integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers.
outputFormat
Output the modified array as a sequence of integers separated by a space.
## sample5
4 3 2 1 5
4 1 2 3 5
</p>