Commit b24490806f5904dbdba15e5c780c15d8340dd4c4
1 parent
caf4de25
modification projetfinalaccent2.c fonctions.h
Showing
2 changed files
with
9 additions
and
8 deletions
Show diff stats
fonctions.h
... | ... | @@ -17,7 +17,7 @@ struct cell { |
17 | 17 | |
18 | 18 | void ajout_tete(wchar_t, struct cell**); |
19 | 19 | |
20 | -struct cell ** insertion(wchar_t, struct cell**); | |
20 | +struct cell ** insertion(wchar_t, struct cell**, int*); | |
21 | 21 | |
22 | 22 | void initialisation_tab_arbre(struct node[]); |
23 | 23 | |
... | ... | @@ -33,4 +33,4 @@ void correction_mot(struct node[]); |
33 | 33 | |
34 | 34 | void desallocationArbre(struct cell**); |
35 | 35 | |
36 | -void desallocationTableauArbre(struct node[]); | |
37 | 36 | \ No newline at end of file |
37 | +void desallocationTableauArbre(struct node[]); | ... | ... |
projetfinalaccent2.c
... | ... | @@ -17,16 +17,17 @@ void ajout_tete(wchar_t elem, struct cell** pL) { |
17 | 17 | *pL = p; |
18 | 18 | } |
19 | 19 | |
20 | -struct cell ** insertion(wchar_t elem, struct cell** pL) { | |
20 | +struct cell ** insertion(wchar_t elem, struct cell** pL, int* lettreAjoute) { | |
21 | 21 | if(((*pL) == NULL) || ((*pL)->arbre->lettre > elem)) { |
22 | 22 | ajout_tete(elem, pL); |
23 | + if(lettreAjoute != NULL) *lettreAjoute = 1; | |
23 | 24 | return &(*pL)->arbre->listeFils; |
24 | 25 | } |
25 | 26 | else if((*pL)->arbre->lettre == elem) { |
26 | 27 | return &(*pL)->arbre->listeFils; |
27 | 28 | } |
28 | 29 | else { |
29 | - return insertion(elem, &(*pL)->arbreSuivant); | |
30 | + return insertion(elem, &(*pL)->arbreSuivant, lettreAjoute); | |
30 | 31 | } |
31 | 32 | } |
32 | 33 | |
... | ... | @@ -45,7 +46,7 @@ void initialisation_tab_arbre(struct node tab[]) { |
45 | 46 | tab[i+5].lettre = ';'; |
46 | 47 | for(int j = 0; j <= 5; j++) { |
47 | 48 | tab[i+j].listeFils = NULL; |
48 | - insertion('\0', &(tab[i+j].listeFils)); | |
49 | + insertion('\0', &(tab[i+j].listeFils), NULL); | |
49 | 50 | } |
50 | 51 | } |
51 | 52 | |
... | ... | @@ -66,9 +67,8 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { |
66 | 67 | int cptmot = 0, indice = 0; |
67 | 68 | wchar_t motLu[50]; |
68 | 69 | while(fwscanf(fd, L"%ls", motLu)==1) { |
69 | - int estUneLettre = 1; | |
70 | + int estUneLettre = 1, lettreAjoute = 0; | |
70 | 71 | int i = 0; |
71 | - cptmot += 1; | |
72 | 72 | if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) { |
73 | 73 | localisationArbre = &tab_arbre_prcp[motLu[0]-65].listeFils; |
74 | 74 | } |
... | ... | @@ -91,8 +91,9 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { |
91 | 91 | } |
92 | 92 | while((motLu[i] != '\0') && (estUneLettre == 1)) { |
93 | 93 | i += 1; |
94 | - localisationArbre = insertion(motLu[i], localisationArbre); | |
94 | + localisationArbre = insertion(motLu[i], localisationArbre, &lettreAjoute); | |
95 | 95 | } |
96 | + if(lettreAjoute == 1) cptmot += 1; | |
96 | 97 | } |
97 | 98 | wprintf(L"\n"); |
98 | 99 | fclose(fd); | ... | ... |