Commit 54b57c55a1a9a57080a5254ab6ad1126130e50ca
1 parent
adcc7f50
création du main + fonctions.h
Showing
5 changed files
with
87 additions
and
47 deletions
Show diff stats
... | ... | @@ -0,0 +1,36 @@ |
1 | +#include <stdio.h> | |
2 | +#include <stdlib.h> | |
3 | +#include <wchar.h> | |
4 | +#include <locale.h> | |
5 | + | |
6 | +#define A 256 | |
7 | + | |
8 | +struct node { | |
9 | + wchar_t lettre; | |
10 | + struct cell* listeFils; | |
11 | +}; | |
12 | + | |
13 | +struct cell { | |
14 | + struct node* arbre; | |
15 | + struct cell* arbreSuivant; | |
16 | +}; | |
17 | + | |
18 | +void ajout_tete(wchar_t, struct cell**); | |
19 | + | |
20 | +struct cell ** insertion(wchar_t, struct cell**); | |
21 | + | |
22 | +void initialisation_tab_arbre(struct node); | |
23 | + | |
24 | +int indice_lettre(struct node, wchar_t); | |
25 | + | |
26 | +void remplir_dico(FILE*, struct node); | |
27 | + | |
28 | +struct cell ** test_mot(wchar_t, struct cell**, int*); | |
29 | + | |
30 | +void correction_txt(FILE, struct node); | |
31 | + | |
32 | +void correction_mot(struct node); | |
33 | + | |
34 | +void desalocationArbre(struct cell**); | |
35 | + | |
36 | +void desalocationTableauArbre(struct node); | |
0 | 37 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,35 @@ |
1 | +#include "fonctions.h" | |
2 | + | |
3 | +#define A 256 | |
4 | + | |
5 | +int main(int argc, char* argv[]) { | |
6 | + | |
7 | + | |
8 | + setlocale(LC_ALL, ""); | |
9 | + FILE* dico = NULL; | |
10 | + FILE* txt = NULL; | |
11 | + struct node tab_arbre[A]; | |
12 | + | |
13 | + if(argc>2) { | |
14 | + dico = fopen(argv[1], "r"); | |
15 | + txt = fopen(argv[2], "r"); | |
16 | + } | |
17 | + else { | |
18 | + dico = NULL; | |
19 | + txt = NULL; | |
20 | + } | |
21 | + if ((dico == NULL) || (txt == NULL)) { | |
22 | + wprintf(L"Erreur : il manque un ou plusieurs fichiers !\n"); | |
23 | + return 1; | |
24 | + } | |
25 | + initialisation_tab_arbre(tab_arbre); | |
26 | + remplir_dico(dico, tab_arbre); | |
27 | + | |
28 | + correction_txt(txt, tab_arbre); | |
29 | + correction_mot(tab_arbre); | |
30 | + desalocationTableauArbre(tab_arbre); | |
31 | + | |
32 | + printf("fini\n"); | |
33 | + | |
34 | + return 0; | |
35 | +} | |
0 | 36 | \ No newline at end of file | ... | ... |
projetfinalaccent2.c
... | ... | @@ -3,17 +3,9 @@ |
3 | 3 | #include <wchar.h> |
4 | 4 | #include <locale.h> |
5 | 5 | |
6 | -#define A 256 | |
7 | - | |
8 | -struct node { | |
9 | - wchar_t lettre; | |
10 | - struct cell* listeFils; | |
11 | -}; | |
6 | +#include "fonctions.h" | |
12 | 7 | |
13 | -struct cell { | |
14 | - struct node* arbre; | |
15 | - struct cell* arbreSuivant; | |
16 | -}; | |
8 | +#define A 256 | |
17 | 9 | |
18 | 10 | void ajout_tete(wchar_t elem, struct cell** pL) { |
19 | 11 | struct cell* p; |
... | ... | @@ -48,14 +40,16 @@ void initialisation_tab_arbre(struct node tab[]) { |
48 | 40 | tab[i].lettre = '?'; |
49 | 41 | tab[i+1].lettre = '!'; |
50 | 42 | tab[i+2].lettre = '\''; |
51 | - for(int j = 0; j <= 2; j++) { //Ajout des caractères de ponctuation par défaut | |
43 | + tab[i+3].lettre = '.'; //Ajout des caractères de ponctuation par défau | |
44 | + tab[i+4].lettre = ':'; | |
45 | + tab[i+5].lettre = ';'; | |
46 | + for(int j = 0; j <= 5; j++) { | |
52 | 47 | tab[i+j].listeFils = NULL; |
53 | 48 | insertion('\0', &(tab[i+j].listeFils)); |
54 | 49 | } |
55 | 50 | } |
56 | 51 | |
57 | -int indice_lettre(struct node tab_arbre_prcp[], wchar_t lettre) | |
58 | -{ | |
52 | +int indice_lettre(struct node tab_arbre_prcp[], wchar_t lettre) { | |
59 | 53 | int i = 0; |
60 | 54 | while(i >= 0 && i < A){ |
61 | 55 | if(lettre == tab_arbre_prcp[i].lettre ){ |
... | ... | @@ -72,7 +66,6 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { |
72 | 66 | int cptmot = 0, indice = 0; |
73 | 67 | wchar_t motLu[50]; |
74 | 68 | while(fwscanf(fd, L"%ls", motLu)==1) { |
75 | - //wprintf(L"mot lu : %ls\n", motLu); | |
76 | 69 | int estUneLettre = 1; |
77 | 70 | int i = 0; |
78 | 71 | cptmot += 1; |
... | ... | @@ -135,7 +128,6 @@ void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) { |
135 | 128 | localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils; |
136 | 129 | } |
137 | 130 | else if((motLu[0] < 'A') || (motLu[0] > 'z')) { |
138 | - printf("jsuisla\n"); | |
139 | 131 | indice = indice_lettre(tab_arbre_prcp, motLu[0]); |
140 | 132 | localisationArbre = &tab_arbre_prcp[indice].listeFils; |
141 | 133 | if(indice == -1) { |
... | ... | @@ -212,7 +204,7 @@ void desalocationArbre(struct cell** pL) { |
212 | 204 | free(*pL); |
213 | 205 | } |
214 | 206 | |
215 | -void desalocationTableauArbre(struct node tab_arbre[]){ | |
207 | +void desalocationTableauArbre(struct node tab_arbre[]) { | |
216 | 208 | int i = 0; |
217 | 209 | for(wchar_t u = 'a'; u < A; u++) { |
218 | 210 | desalocationArbre(&tab_arbre[i].listeFils); |
... | ... | @@ -220,34 +212,3 @@ void desalocationTableauArbre(struct node tab_arbre[]){ |
220 | 212 | } |
221 | 213 | } |
222 | 214 | |
223 | -int main(int argc, char* argv[]) { | |
224 | - | |
225 | - | |
226 | - setlocale(LC_ALL, ""); | |
227 | - FILE* dico = NULL; | |
228 | - FILE* txt = NULL; | |
229 | - struct node tab_arbre[A]; | |
230 | - | |
231 | - if(argc>2) { | |
232 | - dico = fopen(argv[1], "r"); | |
233 | - txt = fopen(argv[2], "r"); | |
234 | - } | |
235 | - else { | |
236 | - dico = NULL; | |
237 | - txt = NULL; | |
238 | - } | |
239 | - if ((dico == NULL) || (txt == NULL)) { | |
240 | - wprintf(L"Erreur : il manque un ou plusieurs fichiers !\n"); | |
241 | - return 1; | |
242 | - } | |
243 | - initialisation_tab_arbre(tab_arbre); | |
244 | - remplir_dico(dico, tab_arbre); | |
245 | - //for(int i = 0; i < A; i++) wprintf(L"%lc\n", tab_arbre[i].lettre); | |
246 | - correction_txt(txt, tab_arbre); | |
247 | - correction_mot(tab_arbre); | |
248 | - desalocationTableauArbre(tab_arbre); | |
249 | - | |
250 | - printf("fini\n"); | |
251 | - | |
252 | - return 0; | |
253 | -} | ... | ... |
projetfinalaccent2.exe
No preview for this file type