forked from menault/2026_TD3_DEV51_Qualite_Algo
opti n3
This commit is contained in:
@@ -71,7 +71,6 @@ Transaction *generer_transactions(int n)
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
/* F1 : trie les transactions par montant croissant, puis par id */
|
||||
int comparer_transactions(const void *a, const void *b)
|
||||
{
|
||||
const Transaction *t1 = a;
|
||||
const Transaction *t2 = b;
|
||||
@@ -91,6 +90,10 @@ int comparer_transactions(const void *a, const void *b)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void trier_par_montant(Transaction *t, int n)
|
||||
{
|
||||
qsort(t, n, sizeof(Transaction), comparer_transactions);
|
||||
}
|
||||
void trier_par_montant(Transaction *t, int n)
|
||||
{
|
||||
qsort(t, n, sizeof(Transaction), comparer_transactions);
|
||||
@@ -115,15 +118,14 @@ int nb_clients_distincts(const Transaction *t, int n)
|
||||
return nb;
|
||||
}
|
||||
|
||||
|
||||
/* 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++)
|
||||
totaux[t[i].client] += t[i].montant;
|
||||
}
|
||||
|
||||
/* F4 : solde total de chaque jour */
|
||||
|
||||
Reference in New Issue
Block a user