#C13184. Median Finder from Standard Input

    ID: 42694 Type: Default 1000ms 256MiB

Median Finder from Standard Input

Median Finder from Standard Input

You are given a list of numbers provided via standard input. Your task is to compute the median of the list. The median is defined as the middle number when the list is sorted in non-decreasing order. If the list has an even number of elements, the median is the average of the two middle numbers.

The program should handle error cases as follows:

  • If no valid input is provided, output The input is empty.
  • If any line of the input contains non-numeric data, output The input contains non-numeric data.

inputFormat

The input is given through standard input (stdin). Each line contains a single number. The input is terminated by end-of-file (EOF). It is possible that the input may be empty or contain invalid (non-numeric) data.

outputFormat

Output the median of the provided numbers to standard output (stdout). If an error occurs because the input is empty or contains non-numeric data, output the corresponding error message exactly as specified.## sample

1
2
3
4
2.5