From 8b61d242056e9f9a4eca4c291db09cda662ee279 Mon Sep 17 00:00:00 2001 From: Maxime Claudel Date: Thu, 4 Apr 2019 12:03:16 +0200 Subject: [PATCH] Projet modifié --- correcteur.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/correcteur.c b/correcteur.c index a139887..d39e28c 100644 --- a/correcteur.c +++ b/correcteur.c @@ -41,22 +41,24 @@ void ajout(Node **N, char mot) } -void ajout_alphab(Node ** pn, char * mot,int cpt) +void ajout_alphab(Node ** pn, char * mot,int cpt,int i) { - int i = 0; while (mot[cpt] != '\0'){ if ((*pn)==NULL){ ajout(pn,mot[cpt]); - return; } while ((*pn)->lettres[i] != NULL){ - if (strcmp(&(*pn)->l,mot) != 0){ + if ((*pn)->l == '?'){ + *pn = (*pn)->lettres[0]; + } + if ((*pn)->l != mot[cpt]){ i++; + return ajout_alphab(&(*pn)->lettres[i],mot,cpt,i); } - *pn=(*pn)->lettres[i]; - return ajout_alphab(pn,mot,cpt++); + cpt++; + return ajout_alphab(&(*pn)->lettres[i],mot,cpt,i); } - (*pn)->dernier++; + (*pn)->dernier ++ ; ajout(&(*pn)->lettres[i],mot[cpt]); *pn=(*pn)->lettres[i]; cpt++; @@ -66,13 +68,18 @@ void ajout_alphab(Node ** pn, char * mot,int cpt) Node * charger_arbre(Node ** Arbre){ - FILE * dico; - char mot[MAX_LETTRES]; - dico = fopen("test.txt","r"); - while (fscanf(dico,"%s",mot) == 1){ - ajout_alphab(Arbre,mot,0); - } - fclose(dico); + // FILE * dico; + //char mot[MAX_LETTRES]; + Node * debut = *Arbre; + //dico = fopen("test.txt","r"); + /* while (fscanf(dico,"%s",mot) == 1){ + ajout_alphab(Arbre,mot,0,0); + }*/ + ajout_alphab(Arbre,"camion",0,0); + *Arbre = debut; + ajout_alphab(Arbre,"casse",0,0); + *Arbre = debut; + //fclose(dico); return *Arbre; } @@ -109,6 +116,7 @@ int main(){ Node * Arbre; initialisation(&Arbre); charger_arbre(&Arbre); + affichage_arbre(Arbre); detruire_arbre(&Arbre); return 0; -- libgit2 0.21.2