Programming contests

50 Programming Exercise for Beginners

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

Super Stars of the Majors

Write a program that writes to the standard output the data of the three best-performing students of a particular major or all of them if there are at most three students in the given major. The data of the students should be presented in the standard output in descending order of their study average. Students having the same study average should be listed in lexicographical order of their Neptun IDs. The study averages should be displayed with one decimal precision.

The data to be processed must be read from the standard input. The first line of the input contains an acronym of a major made up of at most 10 characters. An additional up to 1000 lines of the input are of the following format:

surname first_name neptun_id major study_average

The surname and first_name are strings of up to 30 characters in length, the neptun_id is exactly 6 characters long, the major is an acronym of up to 10 characters, and the study_average is a real number. None of the strings contain space characters.

Sample Input

  1. PTI
  2. Orchidea Dora 123ABC GI 4.5
  3. Ugyes Mark AFG12L GI 4.4
  4. Horvath Csaba ART12M PTI 2.8
  5. Mekk Elek ERTZ12 MI 2.7
  6. Feher Adam ZTI98M GI 3.4
  7. Keves Gabor PRE74W PTI 4.0
  8. Pato Pal QWER99 MI 2.6
  9. Feher Laszlo ASDF89 GI 2.5
  10. Kiss Mark ACDC12 MI 3.8
  11. Elo Arpad XYC78L PTI 4.9
  12. Kemeny Szilard LUK65E PTI 4.0
  13. Kantor Norbert WASD33 MI 3.8
download as text file

Output for Sample Input

  1. Elo Arpad XYC78L 4.9
  2. Kemeny Szilard LUK65E 4.0
  3. Keves Gabor PRE74W 4.0
download as text file

One possible solution is available in: main.c.

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. 03/01/2019