fonction 10 : O(L)

This commit is contained in:
abraham
2026-10-21 11:49:58 +02:00
parent b40a1c2081
commit 7c09526d0a
3 changed files with 11 additions and 5 deletions
+1 -1
View File
@@ -102,7 +102,7 @@ La complexité de la fonction est de <span style="color:blue">[O(n)]</span> pour
- Optimisation de la fonction 9 nom du commit : "". Emprunte : ff68d260a7a58441
- Optimisation de la fonction 10 nom du commit : "". Emprunte : ff68d260a7a58441
- Optimisation de la fonction 10 nom du commit : "fonction 10 : O(L)". Emprunte : ff68d260a7a58441
BIN
View File
Binary file not shown.
+10 -4
View File
@@ -235,10 +235,16 @@ int categorie(const Transaction *t)
/* F10 : ajoute une ligne à la fin du rapport */
int longueur(const char *s)
{
int n = 0;
while (s[n] != '\0')
n++;
return n;
static const char *chaine_connue = NULL;
static int n_connu = 0;
if (s != chaine_connue || s[0] == '\0') {
chaine_connue = s;
n_connu = 0;
}
while (s[n_connu] != '\0')
n_connu++;
return n_connu;
}
void ajouter_ligne(char *rapport, const char *ligne)