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,7 +17,7 @@ struct cell { | ||
17 | 17 | ||
18 | void ajout_tete(wchar_t, struct cell**); | 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 | void initialisation_tab_arbre(struct node[]); | 22 | void initialisation_tab_arbre(struct node[]); |
23 | 23 | ||
@@ -33,4 +33,4 @@ void correction_mot(struct node[]); | @@ -33,4 +33,4 @@ void correction_mot(struct node[]); | ||
33 | 33 | ||
34 | void desallocationArbre(struct cell**); | 34 | void desallocationArbre(struct cell**); |
35 | 35 | ||
36 | -void desallocationTableauArbre(struct node[]); | ||
37 | \ No newline at end of file | 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,16 +17,17 @@ void ajout_tete(wchar_t elem, struct cell** pL) { | ||
17 | *pL = p; | 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 | if(((*pL) == NULL) || ((*pL)->arbre->lettre > elem)) { | 21 | if(((*pL) == NULL) || ((*pL)->arbre->lettre > elem)) { |
22 | ajout_tete(elem, pL); | 22 | ajout_tete(elem, pL); |
23 | + if(lettreAjoute != NULL) *lettreAjoute = 1; | ||
23 | return &(*pL)->arbre->listeFils; | 24 | return &(*pL)->arbre->listeFils; |
24 | } | 25 | } |
25 | else if((*pL)->arbre->lettre == elem) { | 26 | else if((*pL)->arbre->lettre == elem) { |
26 | return &(*pL)->arbre->listeFils; | 27 | return &(*pL)->arbre->listeFils; |
27 | } | 28 | } |
28 | else { | 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,7 +46,7 @@ void initialisation_tab_arbre(struct node tab[]) { | ||
45 | tab[i+5].lettre = ';'; | 46 | tab[i+5].lettre = ';'; |
46 | for(int j = 0; j <= 5; j++) { | 47 | for(int j = 0; j <= 5; j++) { |
47 | tab[i+j].listeFils = NULL; | 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,9 +67,8 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { | ||
66 | int cptmot = 0, indice = 0; | 67 | int cptmot = 0, indice = 0; |
67 | wchar_t motLu[50]; | 68 | wchar_t motLu[50]; |
68 | while(fwscanf(fd, L"%ls", motLu)==1) { | 69 | while(fwscanf(fd, L"%ls", motLu)==1) { |
69 | - int estUneLettre = 1; | 70 | + int estUneLettre = 1, lettreAjoute = 0; |
70 | int i = 0; | 71 | int i = 0; |
71 | - cptmot += 1; | ||
72 | if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) { | 72 | if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) { |
73 | localisationArbre = &tab_arbre_prcp[motLu[0]-65].listeFils; | 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,8 +91,9 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { | ||
91 | } | 91 | } |
92 | while((motLu[i] != '\0') && (estUneLettre == 1)) { | 92 | while((motLu[i] != '\0') && (estUneLettre == 1)) { |
93 | i += 1; | 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 | wprintf(L"\n"); | 98 | wprintf(L"\n"); |
98 | fclose(fd); | 99 | fclose(fd); |