tree.c
1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
typedef struct noeud * Noeud;
struct noeud { char valeur ; Noeud fils[26]; Noeud complet;};
struct dico { struct noeud * tableau[26];};
void cons_noeud (Noeud * pN, char a)
{ int i;
*pN =malloc( sizeof(struct noeud));
(*pN)->valeur=a;
(*pN)->complet=NULL;
for(i=0; i<26; i++)
(*pN)->fils[i]=NULL;
}
void ajout_mot_noeud (Noeud * pN, char *mot)
{
int i;
int n=strlen(mot);
if(*pN == NULL) cons_noeud(pN, tolower(mot[0]));
for(i=1; i<n; i++){
pN=&(*pN)->fils[tolower(mot[i])-97];
if(&(*pN)->valeur==NULL)
cons_noeud(pN, tolower(mot[i]));
}cons_noeud(&(*pN)->complet,49);
}
void ajout_noeud_dico(struct dico * D, Noeud N)
{
int i=0;
while(D->tableau[i]!=NULL)
{i++;}
D->tableau[i]=N;
}
void cons_dico_file(char * nomfichier, struct dico* D)
{
int i;
char * mot;
FILE * fp;
fp=fopen(nomfichier, "r");
if(fp==NULL)
return;
while((fscanf(fp,"%s",mot)==1))
{
ajout_mot_noeud(&(D->tableau[mot[i]-97]),mot);
i++;
}
}
int appartient_dico(struct dico D,char * mot)
{
}
void correction_texte(char* nomfichier, struct dico D)
{
FILE *fp;
fp=fopen(nomfichier, "r+");
char * mot;
if(fp==NULL)
return;
while((fscanf(fp,"%s",mot)==1))
{
if(appartient_dico(D,mot)==1)
return;
else
printf("%s\n"mot);
}
}
int main()
{
return 0;
}