feat: Initial commit
This commit is contained in:
43
TemiEsame/campionato.c
Normal file
43
TemiEsame/campionato.c
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#define MAXN 10
|
||||
#define MAXM 10
|
||||
|
||||
int indMax(int ranking[MAXN], int n) {
|
||||
int ind = 0, max = ranking[0];
|
||||
|
||||
for (int i = 1; i < n; i++) {
|
||||
if (max < ranking[i]) {
|
||||
ind = i;
|
||||
max = ranking[i];
|
||||
}
|
||||
}
|
||||
|
||||
return ind;
|
||||
}
|
||||
|
||||
void displRanking(int C[MAXN][MAXM], int n, int m) {
|
||||
int ranking[MAXM];
|
||||
|
||||
puts("la squadra capolista in ognuna delle nelle 3 giornate è:");
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
ranking[i] = 0;
|
||||
}
|
||||
|
||||
for (int j = 0; j < m; j++) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
ranking[i] += C[i][j];
|
||||
}
|
||||
|
||||
printf(" %d", indMax(ranking, n));
|
||||
}
|
||||
putc('\n', stdout);
|
||||
}
|
||||
|
||||
int main(){
|
||||
int arr[MAXN][MAXM] = {{3,1,0},{0,1,1},{1,1,1},{1,1,3}};
|
||||
displRanking(arr, 4, 3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user