diff --git a/COMPTE_RENDU.md b/COMPTE_RENDU.md index 8a04d39..8239b53 100644 --- a/COMPTE_RENDU.md +++ b/COMPTE_RENDU.md @@ -6,7 +6,9 @@ # 1.Mesurer -```gcc -O2 banque.c -o banque && time ./banque``` +``` +gcc -O2 banque.c -o banque && time ./banque +``` ``` Empreinte : ff68d260a7a58441 @@ -16,7 +18,7 @@ user 0m4,772s sys 0m0,005s ``` -Le temps d'éxecution du programme est de 4.793 seconde et l'emprunte est +Le temps d'éxecution du programme est de 4.793 seconde et l'emprunte est : [ff68d260a7a58441] # 2.Profiler @@ -80,7 +82,27 @@ La complexité de la fonction est de [O(n)] pour +# 4. Optimisation +- Optimisation de la fonction 1 nom du commit : "" + +- Optimisation de la fonction 2 nom du commit : "fonction 2 : O(n + C)". Emprunte : ff68d260a7a58441 + +- Optimisation de la fonction 3 nom du commit : "". Emprunte : ff68d260a7a58441 + +- Optimisation de la fonction 4 nom du commit : "fonction 4 : O(n + J)". Emprunte : ff68d260a7a58441 + +- Optimisation de la fonction 5 nom du commit : "". Emprunte : ff68d260a7a58441 + +- Optimisation de la fonction 6 nom du commit : "". Emprunte : ff68d260a7a58441 + +- Optimisation de la fonction 7 nom du commit : "". Emprunte : ff68d260a7a58441 + +- Optimisation de la fonction 8 nom du commit : "". Emprunte : ff68d260a7a58441 + +- Optimisation de la fonction 9 nom du commit : "". Emprunte : ff68d260a7a58441 + +- Optimisation de la fonction 10 nom du commit : "". Emprunte : ff68d260a7a58441 diff --git a/banque b/banque index 0ae2b46..68876ea 100755 Binary files a/banque and b/banque differ diff --git a/banque.c b/banque.c index e4783a6..7f555e9 100644 --- a/banque.c +++ b/banque.c @@ -88,18 +88,17 @@ void trier_par_montant(Transaction *t, int n) /* F2 : nombre de clients ayant au moins une transaction */ int nb_clients_distincts(const Transaction *t, int n) { + int clients_vus[NB_CLIENTS] = {0}; int nb = 0; + for (int i = 0; i < n; i++) { - int deja_vu = 0; - for (int j = 0; j < i; j++) { - if (t[j].client == t[i].client) { - deja_vu = 1; - break; - } - } - if (!deja_vu) + int client = t[i].client; + if (!clients_vus[client]) { + clients_vus[client] = 1; nb++; + } } + return nb; } @@ -119,10 +118,10 @@ void total_par_jour(const Transaction *t, int n, long *totaux) { for (int j = 0; j < NB_JOURS; j++) { totaux[j] = 0; - for (int i = 0; i < n; i++) - if (t[i].jour == j) - totaux[j] += t[i].montant; } + + for (int i = 0; i < n; i++) + totaux[t[i].jour] += t[i].montant; } /* F5 : période de jours consécutifs dont la somme des soldes est maximale */