Commit 8b61d242056e9f9a4eca4c291db09cda662ee279
1 parent
3b142eb1
Projet modifié
Showing
1 changed file
with
22 additions
and
14 deletions
Show diff stats
correcteur.c
... | ... | @@ -41,22 +41,24 @@ void ajout(Node **N, char mot) |
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | -void ajout_alphab(Node ** pn, char * mot,int cpt) | |
44 | +void ajout_alphab(Node ** pn, char * mot,int cpt,int i) | |
45 | 45 | { |
46 | - int i = 0; | |
47 | 46 | while (mot[cpt] != '\0'){ |
48 | 47 | if ((*pn)==NULL){ |
49 | 48 | ajout(pn,mot[cpt]); |
50 | - return; | |
51 | 49 | } |
52 | 50 | while ((*pn)->lettres[i] != NULL){ |
53 | - if (strcmp(&(*pn)->l,mot) != 0){ | |
51 | + if ((*pn)->l == '?'){ | |
52 | + *pn = (*pn)->lettres[0]; | |
53 | + } | |
54 | + if ((*pn)->l != mot[cpt]){ | |
54 | 55 | i++; |
56 | + return ajout_alphab(&(*pn)->lettres[i],mot,cpt,i); | |
55 | 57 | } |
56 | - *pn=(*pn)->lettres[i]; | |
57 | - return ajout_alphab(pn,mot,cpt++); | |
58 | + cpt++; | |
59 | + return ajout_alphab(&(*pn)->lettres[i],mot,cpt,i); | |
58 | 60 | } |
59 | - (*pn)->dernier++; | |
61 | + (*pn)->dernier ++ ; | |
60 | 62 | ajout(&(*pn)->lettres[i],mot[cpt]); |
61 | 63 | *pn=(*pn)->lettres[i]; |
62 | 64 | cpt++; |
... | ... | @@ -66,13 +68,18 @@ void ajout_alphab(Node ** pn, char * mot,int cpt) |
66 | 68 | |
67 | 69 | |
68 | 70 | Node * charger_arbre(Node ** Arbre){ |
69 | - FILE * dico; | |
70 | - char mot[MAX_LETTRES]; | |
71 | - dico = fopen("test.txt","r"); | |
72 | - while (fscanf(dico,"%s",mot) == 1){ | |
73 | - ajout_alphab(Arbre,mot,0); | |
74 | - } | |
75 | - fclose(dico); | |
71 | + // FILE * dico; | |
72 | + //char mot[MAX_LETTRES]; | |
73 | + Node * debut = *Arbre; | |
74 | + //dico = fopen("test.txt","r"); | |
75 | + /* while (fscanf(dico,"%s",mot) == 1){ | |
76 | + ajout_alphab(Arbre,mot,0,0); | |
77 | + }*/ | |
78 | + ajout_alphab(Arbre,"camion",0,0); | |
79 | + *Arbre = debut; | |
80 | + ajout_alphab(Arbre,"casse",0,0); | |
81 | + *Arbre = debut; | |
82 | + //fclose(dico); | |
76 | 83 | return *Arbre; |
77 | 84 | } |
78 | 85 | |
... | ... | @@ -109,6 +116,7 @@ int main(){ |
109 | 116 | Node * Arbre; |
110 | 117 | initialisation(&Arbre); |
111 | 118 | charger_arbre(&Arbre); |
119 | + | |
112 | 120 | affichage_arbre(Arbre); |
113 | 121 | detruire_arbre(&Arbre); |
114 | 122 | return 0; | ... | ... |