After many setbacks, the Catalan Basketball Federation has succeeded in organizing the Catalan National Basketball 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 basketball teams and then an indeterminate number of results in the form of quadruples:
team1 baskets1 team2 baskets2 |
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 punts_favor; int punts_contra; int guanyats; };
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 vector, you have to program it yourself.
And if so, any sorting method you have studied is valid.
Look at the second example: all teams have won the same number of matches and all have the same basketball average. The teams are sorted in reverse lexicographical order in this case.
Input
An integer n > 1 and n basketball team names followed by an undetermined number of results in the form of quadruplets:
team1 baskets1 team2 baskets2 |
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 Joventut FCBarcelona Girona Lleida Lleida 98 FCBarcelona 88 Lleida 80 Girona 75 Lleida 99 Joventut 56 FCBarcelona 90 Lleida 89 FCBarcelona 110 Girona 90 FCBarcelona 100 Joventut 54 Girona 56 Lleida 68 Girona 67 FCBarcelona 70 Girona 70 Joventut 63 Joventut 93 Lleida 89 Joventut 87 FCBarcelona 79 Joventut 76 Girona 80
Output
Lleida PUNTS: 4 PF: 523 PC: 458 FCBarcelona PUNTS: 4 PF: 537 PC: 485 Girona PUNTS: 2 PF: 438 PC: 467 Joventut PUNTS: 2 PF: 429 PC: 517
Input
4 Joventut FCBarcelona Girona Lleida Lleida 80 FCBarcelona 78 Lleida 80 Girona 78 Lleida 80 Joventut 78 FCBarcelona 80 Lleida 78 FCBarcelona 80 Girona 78 FCBarcelona 80 Joventut 78 Girona 80 Lleida 78 Girona 80 FCBarcelona 78 Girona 80 Joventut 78 Joventut 80 Lleida 78 Joventut 80 FCBarcelona 78 Joventut 80 Girona 78
Output
Lleida PUNTS: 3 PF: 474 PC: 474 Joventut PUNTS: 3 PF: 474 PC: 474 Girona PUNTS: 3 PF: 474 PC: 474 FCBarcelona PUNTS: 3 PF: 474 PC: 474
Input
3 FCBarcelona Girona Lleida Lleida 98 FCBarcelona 88 Lleida 99 Girona 56 FCBarcelona 90 Lleida 89 Girona 67 FCBarcelona 70
Output
Lleida PUNTS: 2 PF: 286 PC: 234 FCBarcelona PUNTS: 2 PF: 248 PC: 254 Girona PUNTS: 0 PF: 123 PC: 169