diff --git a/banque.c b/banque.c index 3b030e6..6a684a9 100644 --- a/banque.c +++ b/banque.c @@ -107,12 +107,10 @@ int nb_clients_distincts(const Transaction *t, int n) /* F3 : solde total de chaque client */ 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; - for (int i = 0; i < n; i++) - if (t[i].client == c) - totaux[c] += t[i].montant; - } + for (int i = 0; i < n; i++) /* un seul parcours : chaque montant va */ + totaux[t[i].client] += t[i].montant; /* directement au total de son client */ } /* F4 : solde total de chaque jour */