0
EXERCISE:
Write a function that returns the number of the team that is in the lead. Leadership is determined by the team that has the most points won. If one or more teams have the same number of points, and used the following tiebreaker criterion: number of wins and goals balance in this order. If, even so, two or more teams have tied, you must return the number of one of the leading teams. The function must receive as parameters the number of teams, n, and the table with the results, tab, and must obey the next prototype:
int lider(int n, int tab[][6]);
#include <stdio.h>
int melhorsaldo(int n, int tab[][6]) {
int l, i=0;
for (l=1;l<n;l++) {
if ((tab[l][4]-tab[l][5]) > (tab[i][4]-tab[i][5])) {
i = l;
}
}
return i;
};
int main() {
int n, l, c, res;
printf("Quantos times sao?\n ");
scanf("%d",&n);
int tab[n][6];
printf("Digite os elementos da matriz\n");
for(l=0; l<n; l++) {
for(c=0; c<6; c++) {
printf("[%d][%d]: ", l, c);
scanf("%d", &tab[l][c]);
}
}
res = melhorsaldo(n, tab);
res++;
printf("\nMelhor saldo de gols, time: %d\n", res);
return 0;
}