forked from menault/2026_TD3_DEV51_Qualite_Algo
fixes F2
This commit is contained in:
@@ -88,19 +88,18 @@ 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)
|
||||
{
|
||||
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)
|
||||
nb++;
|
||||
int nbr_clients = 0;
|
||||
int *deja_vu = (int*) calloc(NB_CLIENTS,sizeof(int));
|
||||
|
||||
for (int i = 0 ; i < n ; i++){
|
||||
if (deja_vu[t[i].client] == 0){
|
||||
deja_vu[t[i].client] = 1;
|
||||
nbr_clients +=1;
|
||||
}
|
||||
}
|
||||
return nb;
|
||||
free(deja_vu);
|
||||
return nbr_clients;
|
||||
|
||||
}
|
||||
|
||||
/* F3 : solde total de chaque client */
|
||||
|
||||
Reference in New Issue
Block a user