forked from menault/2026_TD3_DEV51_Qualite_Algo
Optimiser F4 par accumulation directe des soldes journaliers
This commit is contained in:
@@ -91,11 +91,34 @@ static void tester_totaux_clients(void)
|
||||
assert(totaux[c] == 0);
|
||||
}
|
||||
|
||||
static void tester_totaux_jours(void)
|
||||
{
|
||||
Transaction t[] = {
|
||||
{0, 0, NB_JOURS - 1, 100}, {1, 1, 0, -50},
|
||||
{2, 2, NB_JOURS - 1, -40}, {3, 3, 0, 50}, {4, 4, 7, 0}
|
||||
};
|
||||
long totaux[NB_JOURS];
|
||||
for (int i = 0; i < NB_JOURS; i++)
|
||||
totaux[i] = 123;
|
||||
total_par_jour(t, 5, totaux);
|
||||
for (int j = 0; j < NB_JOURS; j++) {
|
||||
long attendu = 0;
|
||||
for (int i = 0; i < 5; i++)
|
||||
if (t[i].jour == j)
|
||||
attendu += t[i].montant;
|
||||
assert(totaux[j] == attendu);
|
||||
}
|
||||
total_par_jour(NULL, 0, totaux);
|
||||
for (int j = 0; j < NB_JOURS; j++)
|
||||
assert(totaux[j] == 0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
tester_tri();
|
||||
tester_clients_distincts();
|
||||
tester_totaux_clients();
|
||||
tester_totaux_jours();
|
||||
puts("Tests banque : OK");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user