Commit dd84636f9e7d5e1f4e0ee0a390a8ac0bd86dedfd
1 parent
762b7dc2
dernier commit
Showing
5 changed files
with
97 additions
and
622 deletions
Show diff stats
1 | -erA=fopen("dico/A.txt","w"); | |
2 | - FILE *fichierB=fopen("dico/B.txt","w"); | |
3 | - FILE *fichierC=fopen("dico/C.txt","w"); | |
4 | - FILE *fichierD=fopen("dico/D.txt","w"); | |
5 | - FILE *fichierE=fopen("dico/E.txt","w"); | |
6 | - FILE *fichierF=fopen("dico/F.txt","w"); | |
7 | - FILE *fichierG=fopen("dico/G.txt","w"); | |
8 | - FILE *fichierH=fopen("dico/H.txt","w"); | |
9 | - FILE *fichierI=fopen("dico/I.txt","w"); | |
10 | - FILE *fichierJ=fopen("dico/J.txt","w"); | |
11 | - FILE *fichierK=fopen("dico/K.txt","w"); | |
12 | - FILE *fichierL=fopen("dico/L.txt","w"); | |
13 | - FILE *fichierM=fopen("dico/M.txt","w"); | |
14 | - FILE *fichierN=fopen("dico/N.txt","w"); | |
15 | - FILE *fichierO=fopen("dico/O.txt","w"); | |
16 | - FILE *fichierP=fopen("dico/P.txt","w"); | |
17 | - FILE *fichierQ=fopen("dico/Q.txt","w"); | |
18 | - FILE *fichierR=fopen("dico/R.txt","w"); | |
19 | - FILE *fichierS=fopen("dico/S.txt","w"); | |
20 | - FILE *fichierT=fopen("dico/T.txt","w"); | |
21 | - FILE *fichierU=fopen("dico/U.txt","w"); | |
22 | - FILE *fichierV=fopen("dico/V.txt","w"); | |
23 | - FILE *fichierW=fopen("dico/W.txt","w"); | |
24 | - FILE *fichierX=fopen("dico/X.txt","w"); | |
25 | - FILE *fichierY=fopen("dico/Y.txt","w"); | |
26 | - FILE *fichierZ=fopen("dico/Z.txt","w"); | |
27 | - do{ | |
28 | - int n=strlen(ch); | |
29 | - | |
30 | - if((int)ch[0]==97){ | |
31 | - for(i=0;i<n;i++) | |
32 | - fprintf(fichierA,"%c",ch[i]); | |
33 | - fprintf(fichierA,"%s","\n"); | |
34 | - } | |
35 | - | |
36 | - if((int)ch[0]==98){ | |
37 | - for(i=0;i<n;i++) | |
38 | - fprintf(fichierB,"%c",ch[i]); | |
39 | - fprintf(fichierB,"%s","\n"); | |
40 | - } | |
41 | - | |
42 | - if((int)ch[0]==99){ | |
43 | - for(i=0;i<n;i++) | |
44 | - fprintf(fichierC,"%c",ch[i]); | |
45 | - fprintf(fichierC,"%s","\n"); | |
46 | - } | |
47 | - | |
48 | - if((int)ch[0]==100){ | |
49 | - for(i=0;i<n;i++) | |
50 | - fprintf(fichierD,"%c",ch[i]); | |
51 | - fprintf(fichierD,"%s","\n"); | |
52 | - } | |
53 | - | |
54 | - if((int)ch[0]==101){ | |
55 | - for(i=0;i<n;i++) | |
56 | - fprintf(fichierE,"%c",ch[i]); | |
57 | - fprintf(fichierE,"%s","\n"); | |
58 | - } | |
59 | - | |
60 | - if((int)ch[0]==102){ | |
61 | - for(i=0;i<n;i++) | |
62 | - fprintf(fichierF,"%c",ch[i]); | |
63 | - fprintf(fichierF,"%s","\n"); | |
64 | - } | |
65 | - | |
66 | - if((int)ch[0]==103){ | |
67 | - for(i=0;i<n;i++) | |
68 | - fprintf(fichierG,"%c",ch[i]); | |
69 | - fprintf(fichierG,"%s","\n"); | |
70 | - } | |
71 | - | |
72 | - if((int)ch[0]==104){ | |
73 | - for(i=0;i<n;i++) | |
74 | - fprintf(fichierH,"%c",ch[i]); | |
75 | - fprintf(fichierH,"%s","\n");chierI,"%c",ch[i]); | |
76 | - fprintf(fichierI,"%s","\n"); | |
77 | - } | |
78 | - | |
79 | - if((int)ch[0]==106){ | |
80 | - for(i=0;i<n;i++) | |
81 | - fprintf(fichierJ,"%c",ch[i]); | |
82 | - fprintf(fichierJ,"%s","\n"); | |
83 | - } | |
84 | - | |
85 | - if((int)ch[0]==107){ | |
86 | - for(i=0;i<n;i++) | |
87 | - fprintf(fichierK,"%c",ch[i]); | |
88 | - fprintf(fichierK,"%s","\n"); | |
89 | - } | |
90 | - | |
91 | - if((int)ch[0]==108){ | |
92 | - for(i=0;i<n;i++) | |
93 | - fprintf(fichierL,"%c",ch[i]); | |
94 | - fprintf(fichierL,"%s","\n"); | |
95 | - } | |
96 | - | |
97 | - if((int)ch[0]==109){ | |
98 | - for(i=0;i<n;i++) | |
99 | - fprintf(fichierM,"%c",ch[i]); | |
100 | - fprintf(fichierM,"%s","\n"); | |
101 | - } | |
102 | - | |
103 | - if((int)ch[0]==110){ | |
104 | - for(i=0;i<n;i++) | |
105 | - fprintf(fichierN,"%c",ch[i]); | |
106 | - fprintf(fichierN,"%s","\n"); | |
107 | - } | |
108 | - | |
109 | - if((int)ch[0]==111){ | |
110 | - for(i=0;i<n;i++) | |
111 | - fprintf(fichierO,"%c",ch[i]); | |
112 | - fprintf(fichierO,"%s","\n"); | |
113 | - } | |
114 | - | |
115 | - if((int)ch[0]==112){ | |
116 | - for(i=0;i<n;i++) | |
117 | - fprintf(fichierP,"%c",ch[i]); | |
118 | - fprintf(fichierP,"%s","\n"); | |
119 | - } | |
120 | - | |
121 | - if((int)ch[0]==113){ | |
122 | - for(i=0;i<n;i++) | |
123 | - fprintf(fichierQ,"%c",ch[i]); | |
124 | - fprintf(fichierQ,"%s","\n"); | |
125 | - } | |
126 | - | |
127 | - if((int)ch[0]==114){ | |
128 | - for(i=0;i<n;i++) | |
129 | - fprintf(fichierR,"%c",ch[i]); | |
130 | - fprintf(fichierR,"%s","\n"); | |
131 | - } | |
132 | - | |
133 | - if((int)ch[0]==115){ | |
134 | - for(i=0;i<n;i++) | |
135 | - fprintf(fichierS,"%c",ch[i]); | |
136 | - fprintf(fichierS,"%s","\n"); | |
137 | - } | |
138 | - | |
139 | - if((int)ch[0]==116){ | |
140 | - for(i=0;i<n;i++) | |
141 | - fprintf(fichierT,"%c",ch[i]); | |
142 | - fprintf(fichierT,"%s","\n"); | |
143 | - } | |
144 | - | |
145 | - if((int)ch[0]==117){ | |
146 | - for(i=0;i<n;i++) | |
147 | - fprintf(fichierU,"%c",ch[i]); | |
148 | - fprintf(fichierU,"%s","\n"); | |
149 | - } | |
150 | - | |
151 | - if((int)ch[0]==118){ | |
152 | - for(i=0;i<n;i++) | |
153 | - fprintf(fichierV,"%c",ch[i]); | |
154 | - fprintf(fichierV,"%s","\n"); | |
155 | - } | |
156 | - | |
157 | - if((int)ch[0]==119){ | |
158 | - for(i=0;i<n;i++) | |
159 | - fprintf(fichierW,"%c",ch[i]); | |
160 | - fprintf(fichierW,"%s","\n"); | |
161 | - } | |
162 | - | |
163 | - if((int)ch[0]==120){ | |
164 | - for(i=0;i<n;i++) | |
165 | - fprintf(fichierX,"%c",ch[i]); | |
166 | - fprintf(fichierX,"%s","\n"); | |
167 | - } | |
168 | - | |
169 | - if((int)ch[0]==121){ | |
170 | - for(i=0;i<n;i++) | |
171 | - fprintf(fichierY,"%c",ch[i]); | |
172 | - fprintf(fichierY,"%s","\n"); | |
173 | - } | |
174 | - | |
175 | - if((int)ch[0]==122){ | |
176 | - for(i=0;i<n;i++) | |
177 | - fprintf(fichierZ,"%c",ch[i]); | |
178 | - fprintf(fichierZ,"%s","\n"); | |
179 | - } | |
180 | - | |
181 | - | |
182 | - | |
183 | - } while(fscanf(fichier,"%s",&ch)==1); | |
184 | - | |
185 | - fclose(fichierA); | |
186 | - fclose(fichierB); | |
187 | - fclose(fichierC); | |
188 | - fclose(fichierD); | |
189 | - fclose(fichierE); | |
190 | - fclose(fichierF); | |
191 | - fclose(fichierG); | |
192 | - fclose(fichierH); | |
193 | - fclose(fichierI); | |
194 | - fclose(fichierJ); | |
195 | - fclose(fichierK); | |
196 | - fclose(fichierL); | |
197 | - fclose(fichierM); | |
198 | - fclose(fichierN); | |
199 | - fclose(fichierO); | |
200 | - fclose(fichierP); | |
201 | - fclose(fichierQ); | |
202 | - fclose(fichierR); | |
203 | - fclose(fichierS); | |
204 | - fclose(fichierT); | |
205 | - fclose(fichierU); | |
206 | - fclose(fichierV); | |
207 | - fclose(fichierW); | |
208 | - fclose(fichierX); | |
209 | - fclose(fichierY); | |
210 | - fclose(fichierZ); | |
211 | - | |
1 | +#include <stdio.h> | |
2 | +#include <stdlib.h> | |
3 | +#include <string.h> | |
4 | +#include <stdbool.h> | |
5 | +#include <ctype.h> | |
6 | + | |
7 | +typedef struct noeud { | |
8 | + int valeur; | |
9 | + struct noeud *lettre[28]; | |
10 | +} noeud ; | |
11 | + | |
12 | +typedef struct{ | |
13 | + noeud *dictionnaire[26]; | |
14 | +} dico; | |
15 | + | |
16 | +void creer_et_initialiser_le_noeud(noeud ** parbre, int v){ | |
17 | + *parbre=malloc(sizeof(noeud)); | |
18 | + (*parbre)->valeur=v; | |
19 | + for(int i=0;i<28;i++) | |
20 | + (*parbre)->lettre[i]=NULL; | |
21 | +} | |
212 | 22 | |
23 | +void remplissage(noeud ** parbre, char ch[128]){ | |
24 | + int i,n=strlen(ch); | |
25 | + if(*parbre==NULL) | |
26 | + creer_et_initialiser_le_noeud(parbre,tolower(ch[0])); | |
27 | + for(i=1;i<n;i++){ | |
28 | + if(ch[i]==39) | |
29 | + parbre=&(*parbre)->lettre[26]; | |
30 | + else | |
31 | + parbre=&(*parbre)->lettre[tolower(ch[i])-'a']; | |
32 | + if(*parbre == NULL) | |
33 | + creer_et_initialiser_le_noeud(parbre,tolower(ch[i])); | |
213 | 34 | } |
214 | - fclose(fichier); | |
35 | + creer_et_initialiser_le_noeud(&(*parbre)->lettre[27],0); | |
215 | 36 | } |
216 | 37 | |
217 | -void textes(FILE *file){ | |
218 | - char ch[20]; | |
219 | - int i; | |
220 | - if (file != NULL){ | |
221 | - FILE *fileA=fopen("texte/A.txt","w"); | |
222 | - FILE *fileB=fopen("texte/B.txt","w"); | |
223 | - FILE *fileC=fopen("texte/C.txt","w"); | |
224 | - FILE *fileD=fopen("texte/D.txt","w"); | |
225 | - FILE *fileE=fopen("texte/E.txt","w"); | |
226 | - FILE *fileF=fopen("texte/F.txt","w"); | |
227 | - FILE *fileG=fopen("texte/G.txt","w"); | |
228 | - FILE *fileH=fopen("texte/H.txt","w"); | |
229 | - FILE *fileI=fopen("texte/I.txt","w"); | |
230 | - FILE *fileJ=fopen("texte/J.txt","w"); | |
231 | - FILE *fileK=fopen("texte/K.txt","w"); | |
232 | - FILE *fileL=fopen("texte/L.txt","w"); | |
233 | - FILE *fileM=fopen("texte/M.txt","w"); | |
234 | - FILE *fileN=fopen("texte/N.txt","w"); | |
235 | - FILE *fileO=fopen("texte/O.txt","w"); | |
236 | - FILE *fileP=fopen("texte/P.txt","w"); | |
237 | - FILE *fileQ=fopen("texte/Q.txt","w"); | |
238 | - FILE *fileR=fopen("texte/R.txt","w"); | |
239 | - FILE *fileS=fopen("texte/S.txt","w"); | |
240 | - FILE *fileT=fopen("texte/T.txt","w"); | |
241 | - FILE *fileU=fopen("texte/U.txt","w"); | |
242 | - FILE *fileV=fopen("texte/V.txt","w"); | |
243 | - FILE *fileW=fopen("texte/W.txt","w"); | |
244 | - FILE *fileX=fopen("texte/X.txt","w"); | |
245 | - FILE *fileY=fopen("texte/Y.txt","w"); | |
246 | - FILE *fileZ=fopen("texte/Z.txt","w"); | |
247 | - do{ | |
248 | - int n=strlen(ch); | |
249 | - | |
250 | - if((int)ch[0]==97){ | |
251 | - for(i=0;i<n;i++) | |
252 | - fprintf(fileA,"%c",ch[i]); | |
253 | - fprintf(fileA,"%s","\n"); | |
254 | - } | |
255 | - | |
256 | - if((int)ch[0]==98){ | |
257 | - for(i=0;i<n;i++) | |
258 | - fprintf(fileB,"%c",ch[i]); | |
259 | - fprintf(fileB,"%s","\n"); | |
260 | - } | |
261 | - | |
262 | - if((int)ch[0]==99){ | |
263 | - for(i=0;i<n;i++) | |
264 | - fprintf(fileC,"%c",ch[i]); | |
265 | - fprintf(fileC,"%s","\n"); | |
266 | - } | |
267 | - | |
268 | - if((int)ch[0]==100){ | |
269 | - for(i=0;i<n;i++) | |
270 | - fprintf(fileD,"%c",ch[i]); | |
271 | - fprintf(fileD,"%s","\n"); | |
272 | - } | |
273 | - | |
274 | - if((int)ch[0]==101){ | |
275 | - for(i=0;i<n;i++) | |
276 | - fprintf(fileE,"%c",ch[i]); | |
277 | - fprintf(fileE,"%s","\n"); | |
278 | - } | |
279 | - | |
280 | - if((int)ch[0]==102){ | |
281 | - for(i=0;i<n;i++) | |
282 | - fprintf(fileF,"%c",ch[i]); | |
283 | - fprintf(fileF,"%s","\n"); | |
284 | - } | |
285 | - | |
286 | - if((int)ch[0]==103){ | |
287 | - for(i=0;i<n;i++) | |
288 | - fprintf(fileG,"%c",ch[i]); | |
289 | - fprintf(fileG,"%s","\n"); | |
290 | - } | |
291 | - | |
292 | - if((int)ch[0]==104){ | |
293 | - for(i=0;i<n;i++) | |
294 | - fprintf(fileH,"%c",ch[i]); | |
295 | - fprintf(fileH,"%s","\n"); | |
296 | - } | |
297 | - | |
298 | - if((int)ch[0]==105){ | |
299 | - for(i=0;i<n;i++) | |
300 | - fprintf(fileI,"%c",ch[i]); | |
301 | - fprintf(fileI,"%s","\n"); | |
302 | - } | |
303 | - | |
304 | - if((int)ch[0]==106){ | |
305 | - for(i=0;i<n;i++) | |
306 | - fprintf(fileJ,"%c",ch[i]); | |
307 | - fprintf(fileJ,"%s","\n"); | |
308 | - } | |
309 | - | |
310 | - if((int)ch[0]==107){ | |
311 | - for(i=0;i<n;i++) | |
312 | - fprintf(fileK,"%c",ch[i]); | |
313 | - fprintf(fileK,"%s","\n"); | |
314 | - } | |
315 | - | |
316 | - if((int)ch[0]==108){ | |
317 | - for(i=0;i<n;i++) | |
318 | - fprintf(fileL,"%c",ch[i]); | |
319 | - fprintf(fileL,"%s","\n"); | |
320 | - } | |
321 | - | |
322 | - if((int)ch[0]==109){ | |
323 | - for(i=0;i<n;i++) | |
324 | - fprintf(fileM,"%c",ch[i]); | |
325 | - fprintf(fileM,"%s","\n"); | |
326 | - } | |
327 | - | |
328 | - if((int)ch[0]==110){ | |
329 | - for(i=0;i<n;i++) | |
330 | - fprintf(fileN,"%c",ch[i]); | |
331 | - fprintf(fileN,"%s","\n"); | |
332 | - } | |
333 | - | |
334 | - if((int)ch[0]==111){ | |
335 | - for(i=0;i<n;i++) | |
336 | - fprintf(fileO,"%c",ch[i]); | |
337 | - fprintf(fileO,"%s","\n"); | |
338 | - } | |
339 | - | |
340 | - if((int)ch[0]==112){ | |
341 | - for(i=0;i<n;i++) | |
342 | - fprintf(fileP,"%c",ch[i]); | |
343 | - fprintf(fileP,"%s","\n"); | |
344 | - } | |
345 | - | |
346 | - if((int)ch[0]==113){ | |
347 | - for(i=0;i<n;i++) | |
348 | - fprintf(fileQ,"%c",ch[i]); | |
349 | - fprintf(fileQ,"%s","\n"); | |
350 | - } | |
351 | - | |
352 | - if((int)ch[0]==114){ | |
353 | - for(i=0;i<n;i++) | |
354 | - fprintf(fileR,"%c",ch[i]); | |
355 | - fprintf(fileR,"%s","\n"); | |
356 | - } | |
357 | - | |
358 | - if((int)ch[0]==115){ | |
359 | - for(i=0;i<n;i++) | |
360 | - fprintf(fileS,"%c",ch[i]); | |
361 | - fprintf(fileS,"%s","\n"); | |
362 | - } | |
363 | - | |
364 | - if((int)ch[0]==116){ | |
365 | - for(i=0;i<n;i++) | |
366 | - fprintf(fileT,"%c",ch[i]); | |
367 | - fprintf(fileT,"%s","\n"); | |
368 | - } | |
369 | - | |
370 | - if((int)ch[0]==117){ | |
371 | - for(i=0;i<n;i++) | |
372 | - fprintf(fileU,"%c",ch[i]); | |
373 | - fprintf(fileU,"%s","\n"); | |
374 | - } | |
375 | - | |
376 | - if((int)ch[0]==118){ | |
377 | - for(i=0;i<n;i++) | |
378 | - fprintf(fileV,"%c",ch[i]); | |
379 | - fprintf(fileV,"%s","\n"); | |
380 | - } | |
381 | - | |
382 | - if((int)ch[0]==119){ | |
383 | - for(i=0;i<n;i++) | |
384 | - fprintf(fileW,"%c",ch[i]); | |
385 | - fprintf(fileW,"%s","\n"); | |
386 | - } | |
387 | - | |
388 | - if((int)ch[0]==120){ | |
389 | - for(i=0;i<n;i++) | |
390 | - fprintf(fileX,"%c",ch[i]); | |
391 | - fprintf(fileX,"%s","\n"); | |
392 | - } | |
393 | - | |
394 | - if((int)ch[0]==121){ | |
395 | - for(i=0;i<n;i++) | |
396 | - fprintf(fileY,"%c",ch[i]); | |
397 | - fprintf(fileY,"%s","\n"); | |
398 | - } | |
399 | - | |
400 | - if((int)ch[0]==122){ | |
401 | - for(i=0;i<n;i++) | |
402 | - fprintf(fileZ,"%c",ch[i]); | |
403 | - fprintf(fileZ,"%s","\n"); | |
404 | - } | |
405 | - | |
406 | - | |
407 | - | |
408 | - } while(fscanf(file,"%s",&ch)==1); | |
409 | - | |
410 | - fclose(fileA); | |
411 | - fclose(fileB); | |
412 | - fclose(fileC); | |
413 | - fclose(fileD); | |
414 | - fclose(fileE); | |
415 | - fclose(fileF); | |
416 | - fclose(fileG); | |
417 | - fclose(fileH); | |
418 | - fclose(fileI); | |
419 | - fclose(fileJ); | |
420 | - fclose(fileK); | |
421 | - fclose(fileL); | |
422 | - fclose(fileM); | |
423 | - fclose(fileN); | |
424 | - fclose(fileO); | |
425 | - fclose(fileP); | |
426 | - fclose(fileQ); | |
427 | - fclose(fileR); | |
428 | - fclose(fileS); | |
429 | - fclose(fileT); | |
430 | - fclose(fileU); | |
431 | - fclose(fileV); | |
432 | - fclose(fileW); | |
433 | - fclose(fileX); | |
434 | - fclose(fileY); | |
435 | - fclose(fileZ); | |
436 | 38 | |
39 | +void lecture(noeud ** parbre, FILE *fichier,int v){ | |
40 | + char ch[128]; | |
41 | + noeud ** tmp_parbre=parbre; | |
42 | + while(fscanf(fichier,"%s",ch)==1) | |
43 | + if(tolower(ch[0])==v) | |
44 | + remplissage(tmp_parbre,ch); | |
45 | +} | |
437 | 46 | |
47 | +void insertion_dictionnaire(noeud * Arbre[26]){ | |
48 | + int i; | |
49 | + for(i=0;i<26;i++){ | |
50 | + FILE *dico=fopen("dico.txt","r"); | |
51 | + lecture(&Arbre[i],dico,i+'a'); | |
52 | + fclose(dico); | |
438 | 53 | } |
439 | - fclose(file); | |
440 | 54 | } |
441 | 55 | |
442 | -void ascii(int tab[],char ch[]){ | |
443 | - int n=strlen(ch); | |
444 | - int i=0; | |
445 | - for(i=0;i<n;i++) | |
446 | - tab[i]=(int)ch[i]; | |
56 | +void initialiser_dictionnaire(noeud * Arbre[26]){ | |
57 | + int i; | |
58 | + for(i=0;i<26;i++) | |
59 | + Arbre[i]=NULL; | |
447 | 60 | } |
448 | 61 | |
449 | -//mettre en place un algorithme de recherche | |
450 | -int existe(noeud * arbre, char ch){ | |
451 | - if ((int)ch==arbre->valeur) | |
452 | - return 1; | |
453 | - else | |
454 | - return 0; | |
455 | -} | |
456 | -/* | |
457 | -bool repeat(noeud * arbre,char ch[]){ | |
458 | - int cpt=0; | |
62 | +int existe(noeud ** parbre,char ch[128]){ | |
459 | 63 | int n=strlen(ch); |
460 | - int i; | |
461 | - for(i=0;i<n;i++){ | |
462 | - if(ch[i]='a') | |
463 | - cpt=cpt+existe(arbre->a,ch[i]); | |
64 | + int a,cpt=0; | |
65 | + noeud ** tmp_parbre=parbre; | |
66 | + for(int i=0;i<n-1;i++){ | |
67 | + if((*tmp_parbre)!=NULL){ | |
68 | + if(tolower(ch[i])==(*tmp_parbre)->valeur){ | |
69 | + cpt++; | |
70 | + if (ch[i+1]==39) | |
71 | + tmp_parbre=&(*tmp_parbre)->lettre[26]; | |
72 | + else | |
73 | + tmp_parbre=&(*tmp_parbre)->lettre[tolower(ch[i+1])-'a']; | |
74 | + } | |
75 | + } | |
464 | 76 | } |
465 | - if(cpt==n) | |
466 | - return 1; | |
467 | - else | |
468 | - return 0; */ | |
469 | - | |
470 | - | |
471 | - | |
472 | - | |
473 | - | |
474 | - | |
475 | - | |
476 | -//void verification(noeud ** arbre, FILE *fichier){ | |
477 | - // char ch[20] | |
478 | - | |
479 | -// do{ | |
480 | - // existe(&(*arbre),ch); | |
481 | - //}while(fscanf(file,"%s",&ch)==1); | |
482 | - | |
483 | -int main(){ | |
484 | - | |
485 | - | |
486 | - | |
487 | - noeud *ArbreA = NULL; | |
488 | - noeud *ArbreB = NULL; | |
489 | - noeud *ArbreC = NULL; | |
490 | - noeud *ArbreD = NULL; | |
491 | - noeud *ArbreE = NULL; | |
492 | - noeud *ArbreF = NULL; | |
493 | - noeud *ArbreG = NULL; | |
494 | - noeud *ArbreH = NULL; | |
495 | - noeud *ArbreI = NULL; | |
496 | - noeud *ArbreJ = NULL; | |
497 | - noeud *ArbreK = NULL; | |
498 | - noeud *ArbreL = NULL; | |
499 | - noeud *ArbreM = NULL; | |
500 | - noeud *ArbreN = NULL; | |
501 | - noeud *ArbreO = NULL; | |
502 | - noeud *ArbreP = NULL; | |
503 | - noeud *ArbreQ = NULL; | |
504 | - noeud *ArbreR = NULL; | |
505 | - noeud *ArbreS = NULL; | |
506 | - noeud *ArbreT = NULL; | |
507 | - noeud *ArbreU = NULL; | |
508 | - noeud *ArbreV = NULL; | |
509 | - noeud *ArbreW = NULL; | |
510 | - noeud *ArbreX = NULL; | |
511 | - noeud *ArbreY = NULL; | |
512 | - noeud *ArbreZ = NULL; | |
513 | - | |
514 | - | |
515 | - FILE *dico=fopen("dico/dico.txt","r"); | |
516 | - | |
517 | - FILE *fichierA=fopen("dico/A.txt","r"); | |
518 | - FILE *fichierB=fopen("dico/B.txt","r"); | |
519 | - FILE *fichierC=fopen("dico/C.txt","r"); | |
520 | - FILE *fichierD=fopen("dico/D.txt","r"); | |
521 | - FILE *fichierE=fopen("dico/E.txt","r"); | |
522 | - FILE *fichierF=fopen("dico/F.txt","r"); | |
523 | - FILE *fichierG=fopen("dico/G.txt","r"); | |
524 | - FILE *fichierH=fopen("dico/H.txt","r"); | |
525 | - FILE *fichierI=fopen("dico/I.txt","r"); | |
526 | - FILE *fichierJ=fopen("dico/J.txt","r"); | |
527 | - FILE *fichierK=fopen("dico/K.txt","r"); | |
528 | - FILE *fichierL=fopen("dico/L.txt","r"); | |
529 | - FILE *fichierM=fopen("dico/M.txt","r"); | |
530 | - FILE *fichierN=fopen("dico/N.txt","r"); | |
531 | - FILE *fichierO=fopen("dico/O.txt","r"); | |
532 | - FILE *fichierP=fopen("dico/P.txt","r"); | |
533 | - FILE *fichierQ=fopen("dico/Q.txt","r"); | |
534 | - FILE *fichierR=fopen("dico/R.txt","r"); | |
535 | - FILE *fichierS=fopen("dico/S.txt","r"); | |
536 | - FILE *fichierT=fopen("dico/T.txt","r"); | |
537 | - FILE *fichierU=fopen("dico/U.txt","r"); | |
538 | - FILE *fichierV=fopen("dico/V.txt","r"); | |
539 | - FILE *fichierW=fopen("dico/W.txt","r"); | |
540 | - FILE *fichierX=fopen("dico/X.txt","r"); | |
541 | - FILE *fichierY=fopen("dico/Y.txt","r"); | |
542 | - FILE *fichierZ=fopen("dico/Z.txt","r"); | |
543 | - | |
544 | - | |
545 | - dicos(dico); | |
546 | - remplissage(&ArbreA,fichierA); | |
547 | - printf("apres remplissage\n"); | |
548 | - | |
549 | - | |
550 | -/* | |
551 | - | |
552 | - lecture(&ArbreA,fichierA); | |
553 | - lecture(&ArbreB,fichierB); | |
554 | - lecture(&ArbreC,fichierC); | |
555 | - lecture(&ArbreD,fichierD); | |
556 | - lecture(&ArbreE,fichierE); | |
557 | - lecture(&ArbreF,fichierF); | |
558 | - lecture(&ArbreG,fichierG); | |
559 | - lecture(&ArbreH,fichierH); | |
560 | - lecture(&ArbreI,fichierI); | |
561 | - lecture(&ArbreJ,fichierJ); | |
562 | - lecture(&ArbreK,fichierK); | |
563 | - lecture(&ArbreL,fichierL); | |
564 | - lecture(&ArbreM,fichierM); | |
565 | - lecture(&ArbreN,fichierN); | |
566 | - lecture(&ArbreO,fichierO); | |
567 | - lecture(&ArbreP,fichierP); | |
568 | - lecture(&ArbreQ,fichierQ); | |
569 | - lecture(&ArbreR,fichierR); | |
570 | - lecture(&ArbreS,fichierS); | |
571 | - lecture(&ArbreT,fichierT); | |
572 | - lecture(&ArbreU,fichierU); | |
573 | - lecture(&ArbreV,fichierV); | |
574 | - lecture(&ArbreW,fichierW); | |
575 | - lecture(&ArbreX,fichierX); | |
576 | - lecture(&ArbreY,fichierY); | |
577 | - lecture(&ArbreZ,fichierZ); | |
578 | -*/ | |
579 | - | |
580 | - | |
581 | - | |
582 | - fclose(dico); | |
583 | - | |
584 | - fclose(fichierA); | |
585 | - fclose(fichierB); | |
586 | - fclose(fichierC); | |
587 | - fclose(fichierD); | |
588 | - fclose(fichierE); | |
589 | - fclose(fichierF); | |
590 | - fclose(fichierG); | |
591 | - fclose(fichierH); | |
592 | - fclose(fichierI); | |
593 | - fclose(fichierJ); | |
594 | - fclose(fichierK); | |
595 | - fclose(fichierL); | |
596 | - fclose(fichierM); | |
597 | - fclose(fichierN); | |
598 | - fclose(fichierO); | |
599 | - fclose(fichierP); | |
600 | - fclose(fichierQ); | |
601 | - fclose(fichierR); | |
602 | - fclose(fichierS); | |
603 | - fclose(fichierT); | |
604 | - fclose(fichierU); | |
605 | - fclose(fichierV); | |
606 | - fclose(fichierW); | |
607 | - fclose(fichierX); | |
608 | - fclose(fichierY); | |
609 | - fclose(fichierZ); | |
610 | - | |
611 | - printf("apres fclose\n"); | |
612 | -/* | |
613 | - FILE *texte=fopen("texte/texte.txt","r"); | |
614 | - textes(texte); | |
615 | - fclose(texte); | |
616 | - | |
617 | - FILE *corrige = fopen("fautes.txt","w"); | |
618 | - fclose(corrige); */ | |
619 | - printf("Ici\n"); | |
620 | - printf("il existe "); | |
621 | - printf(": %d en valeur",ArbreA->valeur); | |
622 | - printf("apres\n"); | |
623 | -// int i,n=strlen(ch) existe(&(*ArbreA->e),'e') | |
624 | -// int tab[n]; | |
625 | -// ascii(tab,ch); | |
626 | -// for(i=0;i<n;i++) | |
627 | -// printf("%d\n",tab[i]); | |
77 | + if ((*tmp_parbre)!=NULL){ | |
78 | + if (tolower(ch[cpt])==(*tmp_parbre)->valeur) | |
79 | + if ((*tmp_parbre)->lettre[27]!=NULL) | |
80 | + a=1; | |
81 | + } | |
82 | + else a=0; | |
83 | + return a; | |
84 | +} | |
85 | +void corriger_texte(noeud*arbre[26]){ | |
86 | + char ch[128]; | |
87 | + FILE *texte=fopen("texte.txt","r"); | |
88 | + while(fscanf(texte,"%s",ch)==1){ | |
89 | + if(!existe(&arbre[tolower(ch[0])-'a'],ch)) | |
90 | + printf("%s\n",ch); | |
91 | + } | |
92 | + fclose(texte); | |
93 | +} | |
628 | 94 | |
95 | +int main (){ | |
96 | + dico d; | |
97 | + initialiser_dictionnaire(d.dictionnaire); | |
98 | + insertion_dictionnaire(d.dictionnaire); | |
99 | + printf("-----------------------------------------------------------\n"); | |
100 | + printf("Bienvenue dans le correcteur orthographique de HAROUN V1.0\n"); | |
101 | + printf("-----------------------------------------------------------\n"); | |
102 | + printf("\nvoici les fautes dans le texte: \n \n"); | |
103 | + corriger_texte(d.dictionnaire); | |
104 | + printf("\n"); | |
629 | 105 | |
630 | 106 | return 0; |
631 | - | |
632 | - | |
633 | 107 | } |
108 | + | ... | ... |
a.out
No preview for this file type
executable
No preview for this file type
projet.c
... | ... | @@ -59,11 +59,11 @@ void initialiser_dictionnaire(noeud * Arbre[26]){ |
59 | 59 | Arbre[i]=NULL; |
60 | 60 | } |
61 | 61 | |
62 | -bool existe(noeud ** parbre,char ch[128]){ | |
62 | +int existe(noeud ** parbre,char ch[128]){ | |
63 | 63 | int n=strlen(ch); |
64 | - int i,cpt=0; | |
64 | + int a,cpt=0; | |
65 | 65 | noeud ** tmp_parbre=parbre; |
66 | - for(i=0;i<n-1;i++){ | |
66 | + for(int i=0;i<n-1;i++){ | |
67 | 67 | if((*tmp_parbre)!=NULL){ |
68 | 68 | if(tolower(ch[i])==(*tmp_parbre)->valeur){ |
69 | 69 | cpt++; |
... | ... | @@ -77,11 +77,11 @@ bool existe(noeud ** parbre,char ch[128]){ |
77 | 77 | if ((*tmp_parbre)!=NULL){ |
78 | 78 | if (tolower(ch[cpt])==(*tmp_parbre)->valeur) |
79 | 79 | if ((*tmp_parbre)->lettre[27]!=NULL) |
80 | - return true; | |
80 | + a=1; | |
81 | 81 | } |
82 | - else return false; | |
82 | + else a=0; | |
83 | + return a; | |
83 | 84 | } |
84 | - | |
85 | 85 | void corriger_texte(noeud*arbre[26]){ |
86 | 86 | char ch[128]; |
87 | 87 | FILE *texte=fopen("texte.txt","r"); | ... | ... |
projet.o
No preview for this file type