Programming contests

50 Programming Exercise for Beginners

January 2, 2019, 12:00 AM – December 31, 2019, 12:00 AM

Median

Write a program that reads three integers per line from the standard input until three zeros are read. Except for the last scanned line, the program should write the median of the three scanned numbers (the middle of the sorted elements) for each line.

Sample Input

  1. 3 2 5
  2. 3 3 4
  3. -1 0 8
  4. 0 5 0
  5. 0 0 0
download as text file

Output for Sample Input

  1. 3
  2. 3
  3. 0
  4. 0
download as text file
Acknowledgement This work was supported by the construction EFOP-3.4.3-16-2016-00021. The project was supported by the European Union, co-financed by the European Social Fund.
University of Debrecen; Faculty of Informatics; v. 09/30/2024