diff --git a/banque.c b/banque.c index 6e833e6..6180c2f 100644 --- a/banque.c +++ b/banque.c @@ -89,17 +89,13 @@ void trier_par_montant(Transaction *t, int n) /* F2 : nombre de clients ayant au moins une transaction */ int nb_clients_distincts(const Transaction *t, int n) { + char vu[NB_CLIENTS] = {0}; /* vu[c] vaut 1 dès qu'une transaction du client c est rencontrée */ int nb = 0; for (int i = 0; i < n; i++) { - int deja_vu = 0; - for (int j = 0; j < i; j++) { - if (t[j].client == t[i].client) { - deja_vu = 1; - break; - } - } - if (!deja_vu) + if (!vu[t[i].client]) { + vu[t[i].client] = 1; nb++; + } } return nb; }