forked from menault/2026_TD3_DEV51_Qualite_Algo
EXO 4 - optimisation F3
This commit is contained in:
@@ -102,14 +102,14 @@ int nb_clients_distincts(const Transaction *t, int n)
|
|||||||
return nb;
|
return nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* F3 : solde total de chaque client */
|
/* F3 : solde total de chaque client en O(n + c) */
|
||||||
void total_par_client(const Transaction *t, int n, long *totaux)
|
void total_par_client(const Transaction *t, int n, long *totaux)
|
||||||
{
|
{
|
||||||
for (int c = 0; c < NB_CLIENTS; c++) {
|
for (int c = 0; c < NB_CLIENTS; c++) {
|
||||||
totaux[c] = 0;
|
totaux[c] = 0;
|
||||||
for (int i = 0; i < n; i++)
|
}
|
||||||
if (t[i].client == c)
|
for (int i = 0; i < n; i++) {
|
||||||
totaux[c] += t[i].montant;
|
totaux[t[i].client] += t[i].montant;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user