This commit is contained in:
2026-10-26 15:41:53 +01:00
parent 6eb65d3903
commit 3cbbca5735
+8 -6
View File
@@ -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 */