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 and different names of Catalan football teams and then an indeterminate number of results in the form of quadruples:
which represent the result of a match, calculate the final classification taking into account that the order is given by:
The number of points (match won: 3 points, match tied: 1 point).
In case of a tie on points, the team with the best goal difference (difference between goals scored and goals conceded) goes first.
In case of a tie in both previous cases, the team with the smallest team name in lexicographical order.
To make this program you need to use this structure:
struct Equip
{
string nom;
int gols_favor;
int gols_contra;
int guanyats;
int empatats;
};
The number 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 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.
An integer and soccer team names followed by an undetermined number of results in the form of quadruplets:
representing the result of a match.
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