#K16336. Sort the Odd Numbers
Sort the Odd Numbers
Sort the Odd Numbers
You are given an array of non-negative integers. Your task is to sort only the odd numbers in ascending order while keeping the even numbers in their original positions. For example, if the input array is [5, 3, 2, 8, 1, 4], the output should be [1, 3, 2, 8, 5, 4].
Input Format: The first line contains an integer \(n\) representing the number of elements. The second line contains \(n\) space-separated integers.
Output Format: Output the transformed array as a sequence of space-separated integers in one line.
Note: Only the odd numbers are sorted. The even numbers maintain their original positions.
inputFormat
The first line contains an integer \(n\) (the number of elements in the array). The second line contains \(n\) non-negative integers separated by spaces.
outputFormat
Print the transformed array after sorting the odd numbers in ascending order while keeping even numbers at their original positions. The numbers should be printed in a single line separated by a space.
## sample6
5 3 2 8 1 4
1 3 2 8 5 4