forked from menault/2026_TD3_DEV51_Qualite_Algo
Optimiser F3 par accumulation directe des soldes clients
This commit is contained in:
@@ -69,10 +69,33 @@ static void tester_clients_distincts(void)
|
||||
assert(nb_clients_distincts(t, 1) == 1);
|
||||
}
|
||||
|
||||
static void tester_totaux_clients(void)
|
||||
{
|
||||
Transaction t[] = {
|
||||
{0, 0, 0, 100}, {1, NB_CLIENTS - 1, 1, -50},
|
||||
{2, 0, 2, -40}, {3, NB_CLIENTS - 1, 3, 50}, {4, 7, 4, 0}
|
||||
};
|
||||
long totaux[NB_CLIENTS];
|
||||
for (int i = 0; i < NB_CLIENTS; i++)
|
||||
totaux[i] = 123;
|
||||
total_par_client(t, 5, totaux);
|
||||
for (int c = 0; c < NB_CLIENTS; c++) {
|
||||
long attendu = 0;
|
||||
for (int i = 0; i < 5; i++)
|
||||
if (t[i].client == c)
|
||||
attendu += t[i].montant;
|
||||
assert(totaux[c] == attendu);
|
||||
}
|
||||
total_par_client(NULL, 0, totaux);
|
||||
for (int c = 0; c < NB_CLIENTS; c++)
|
||||
assert(totaux[c] == 0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
tester_tri();
|
||||
tester_clients_distincts();
|
||||
tester_totaux_clients();
|
||||
puts("Tests banque : OK");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user