forked from menault/2026_TD3_DEV51_Qualite_Algo
opti n2
This commit is contained in:
@@ -96,21 +96,22 @@ void trier_par_montant(Transaction *t, int n)
|
|||||||
qsort(t, n, sizeof(Transaction), comparer_transactions);
|
qsort(t, n, sizeof(Transaction), comparer_transactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* F2 : nombre de clients ayant au moins une transaction */
|
||||||
/* F2 : nombre de clients ayant au moins une transaction */
|
/* F2 : nombre de clients ayant au moins une transaction */
|
||||||
int nb_clients_distincts(const Transaction *t, int n)
|
int nb_clients_distincts(const Transaction *t, int n)
|
||||||
{
|
{
|
||||||
int nb = 0;
|
int nb = 0;
|
||||||
|
int vus[NB_CLIENTS] = {0};
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
int deja_vu = 0;
|
int client = t[i].client;
|
||||||
for (int j = 0; j < i; j++) {
|
|
||||||
if (t[j].client == t[i].client) {
|
if (!vus[client]) {
|
||||||
deja_vu = 1;
|
vus[client] = 1;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!deja_vu)
|
|
||||||
nb++;
|
nb++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nb;
|
return nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user