Problem 3
PRF192 - Examination 01
[3 Points]
The median of an array is computed as follow:
• Sort the array in ascending order.
• If the array has an odd number of elements, the median is the middle element.

If the array has an even number of elements, the median is the average of the two middle
elements.
Your task here is to write a program to find the median of the given array.
Input
The first line contains the number of elements, n.
The second line contains n space-separated elements: {a1, .., an}.
Constraint

1<n<100

a; EN, for 1≤i≤n.

-3*10°<a≤3*10%, for 1≤i≤n.
Output
One number, rounded to two decimal places, representing the median of given array.
Sample Input
Output Explanation
testcase
Testcase 15
2.00
5 19 1 2
Testcase 2 6
8 3 2 1 6 9
4.50
Sort the array in ascending order:
1 1 2 5 9
Since number of elements is odd, the
median is the middle element: 2.00
Sort the array in ascending order:
1 2 3 6 8 9
Since number of elements is even,
the median is the average of the two
middle elements: (36)/2 4.50
=