After many setbacks, the Catalan Football Federation has succeeded in organizing the Catalan National Football League and has asked the FIB to help them with the management of the season’s results data.
Specifically, you must write a program such that given an integer n ≥ 2 and n different names of Catalan football teams and then an indeterminate number of results in the form of quadruples:
team1 goals1 team2 goals2 |
which represent the result of a match, calculate the final classification taking into account that the order is given by:
To make this program you need to use this structure:
struct Equip { string nom; int gols_favor; int gols_contra; int guanyats; int empatats; };
Observation
The number n ≥ 2 of teams does not necessarily have to be even. Similarly, the matches that will be played do not necessarily have to be all possible (that is, all against all at home and away).
Although it is irrelevant to your program, a match cannot appear more than once, not even with different results.
Only teams that appeared in the initial list of n teams will appear in a match.
You cannot use the sort
operation from the stl
library.
If you need to sort any vectors, you have to program it yourself.
And if so, any of the sorting methods you have studied are valid.
Look at the second example: all teams have won the same number of matches and all have the same goal difference. The teams are sorted in this case in lexicographical order.
Input
An integer n ≥ 2 and n soccer team names followed by an undetermined number of results in the form of quadruplets:
team1 goals1 team2 goals2 |
representing the result of a match.
Output
The final classification in the format indicated in the examples, and with the sorting criteria mentioned in the statement.
Input
4 CEEuropa FCBarcelona Girona Olot CEEuropa 2 FCBarcelona 1 CEEuropa 2 Girona 2 CEEuropa 5 Olot 0 FCBarcelona 4 CEEuropa 3 FCBarcelona 3 Girona 3 FCBarcelona 2 Olot 1 Girona 3 CEEuropa 3 Girona 2 FCBarcelona 2 Girona 2 Olot 2 Olot 2 CEEuropa 2 Olot 1 FCBarcelona 1 Olot 2 Girona 3
Output
CEEuropa PUNTS: 9 GF: 17 GC: 12 FCBarcelona PUNTS: 9 GF: 13 GC: 12 Girona PUNTS: 8 GF: 15 GC: 14 Olot PUNTS: 3 GF: 8 GC: 15
Input
4 Girona Olot CEEuropa FCBarcelona CEEuropa 2 FCBarcelona 1 CEEuropa 2 Girona 1 CEEuropa 2 Olot 1 FCBarcelona 2 CEEuropa 1 FCBarcelona 2 Girona 1 FCBarcelona 2 Olot 1 Girona 2 CEEuropa 1 Girona 2 FCBarcelona 1 Girona 2 Olot 1 Olot 2 CEEuropa 1 Olot 2 FCBarcelona 1 Olot 2 Girona 1
Output
CEEuropa PUNTS: 9 GF: 9 GC: 9 FCBarcelona PUNTS: 9 GF: 9 GC: 9 Girona PUNTS: 9 GF: 9 GC: 9 Olot PUNTS: 9 GF: 9 GC: 9
Input
3 CEEuropa FCBarcelona Olot CEEuropa 2 FCBarcelona 1 CEEuropa 5 Olot 0 FCBarcelona 4 CEEuropa 3 Olot 2 CEEuropa 2
Output
CEEuropa PUNTS: 7 GF: 12 GC: 7 FCBarcelona PUNTS: 3 GF: 5 GC: 5 Olot PUNTS: 1 GF: 2 GC: 7