Programming contests

50 Programming Exercise for Beginners

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

Shrek

Once upon a time, in a far marsh, lived a grumpy ogre called Shrek in cosy loneliness. But the silence and the life of the green monster was disturbed one day by a strange event: fairy-tale creatures swarned the marsh – and surprised our unsuspecting hero.

The three blind mice were running over his dinner, the big wicked wolf was lying in his bed, the seven dwarves put Snow White’s coffin on his desk, and three homeless little pigs were lurking in front of his hut and all the other magical figures that had been chased away by the evil Farquaad lord.

So Shrek is going to the lord to reclaim his marsh. In the great adventure, the ogre also finds a companion: a talkative Donkey, who would do anything for Shrek, except for one thing: he is not willing to keep his mouth closed for all the treasures of the world. But the Donkey likes to put his nose into everything, so he offers a deal: he’s willing to be slient for a few minutes if Shrek shares with him the characteristics of the three most irritating creatures.

Write a program that reads data of fairy tale creatures from the standard input until end-of-file, at least 3, up to 30, one per line. A line is structured as follows:

creature_name;irritation_factor;note

creature_name is a unique string of at most 30 characters, containing only English letters and spaces. irritation_factor is a real number between 0 and 100, while note is a string containing up to 30 characters, describing the grievance caused by the creature, with only English letters and spaces. Data in the line are separated from each other by semicolon (;) characters.

More annoying of two fairy tale creatures is the one having a higher irritation factor. In case of two equally annoying creatures – to try Shrek’s and your knowledge – the Donkey asks them in reversed lexicographical order of their names.

Exactly three lines have to be written to the standard output, each of them containing the name, irritation factor, and note of a fairy tale creature in the following format:

creature_name (irritation_factor): note

Values describing the irritation factor of the creatures are to be displayed with one decimal precision.

Sample Input

  1. A gonosz farkas;47.01;elfoglalta a fekhelyemet
  2. Hofeherke;30.75;jatssza itt a halottat
  3. Egy kismalac;50.22;egyfolytaban rofog
  4. Masik kismalac;60.323;sokat beszel
  5. Harmadik kismalac;50.22;pusztan idegesit
download as text file

Output for Sample Input

  1. Masik kismalac (60.3): sokat beszel
  2. Harmadik kismalac (50.2): pusztan idegesit
  3. Egy kismalac (50.2): egyfolytaban rofog
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