Commit af1143d134c2811bbdff9bc0095dc6bdb9fcdce2
1 parent
4e00a1e4
projet
Showing
1 changed file
with
53 additions
and
79 deletions
Show diff stats
... | ... | @@ -4,91 +4,63 @@ |
4 | 4 | #define size 50 |
5 | 5 | #define taille 26 |
6 | 6 | |
7 | -struct Noeud { char valeur;struct liste * fils; int complet;}; | |
7 | +struct noeud { char valeur; struct noeud * fils[28]; int complet;}; | |
8 | +struct dico {struct noeud* tableau[26];}; | |
9 | +typedef struct noeud* Noeud; | |
8 | 10 | |
9 | -struct liste { struct Noeud * noeud; struct liste * suivant;}; | |
10 | 11 | |
11 | -struct dico {struct Noeud tableau[26];int dernier;}; | |
12 | - | |
13 | -//typedef struct liste* liste; | |
14 | - | |
15 | -typedef struct Noeud Noeud; | |
16 | - | |
17 | - | |
18 | -Noeud* cons_noeud (char a) | |
12 | +void cons_noeud (Noeud * pN, char a) | |
19 | 13 | { |
20 | - Noeud * N = malloc(sizeof(struct Noeud)); | |
21 | - N->valeur=a; | |
22 | - N->fils=NULL; | |
23 | - N->complet=0; | |
24 | - return N; | |
14 | + *pN = malloc(sizeof(struct noeud)); | |
15 | + (*pN)->valeur=a; | |
16 | + (*pN)->complet=0; | |
17 | + for(int i=0; i<28; i++) | |
18 | + { | |
19 | + (*pN)->fils[i]=NULL; | |
20 | + } | |
25 | 21 | } |
26 | - | |
27 | -/*void ajout_lettre (Noeud * N , char a) | |
22 | + | |
23 | +void ajout_noeud_dico(struct dico * D, Noeud N) | |
28 | 24 | { |
29 | - if(N==NULL) | |
30 | - N=cons_noeud(a); | |
31 | - else | |
32 | - | |
33 | - ((N->fils)->noeud)->valeur=a; | |
34 | - ((N->fils)->noeud)->fils=NULL; | |
35 | - (N->fils)->suivant=NULL; | |
25 | + int i=0; | |
26 | + while(D->tableau[i]!=NULL) | |
27 | + {i++;} | |
28 | + D->tableau[i]=N; | |
29 | +} | |
36 | 30 | |
37 | - | |
38 | - }*/ | |
31 | +void ajout_mot(Noeud * pN, char mot[size]) | |
32 | +{ | |
33 | + if(*pN==NULL) | |
34 | + { | |
35 | + cons_noeud(pN,mot[0]); | |
36 | + sup_lettre(mot); | |
37 | + } | |
38 | + else | |
39 | + | |
40 | +} | |
39 | 41 | |
40 | -//Reprendre cette fonction! | |
41 | -void ajout_mot (struct dico * D, char mot[size]) | |
42 | +char * sup_lettre(char mot[size]) | |
42 | 43 | { |
43 | - Noeud *N; | |
44 | - int j = 0 ; | |
45 | - while (j<D->dernier && D->tableau[j].valeur != mot[0]) | |
46 | - j++ ; | |
47 | - if(j < D->dernier) | |
48 | - { | |
49 | - N=&(D->tableau[j]); | |
50 | - } | |
51 | - else | |
52 | - { | |
53 | - N=cons_noeud(mot[0]); | |
44 | + for(int i=1; i<size; i++) | |
45 | + { | |
46 | + mot[i]= mot[i+1]; | |
54 | 47 | } |
55 | - | |
56 | - for (int i=1; i<size; i++) | |
57 | - | |
58 | - { | |
59 | - if((N->fils->noeud)!=NULL) | |
60 | - { | |
61 | - N=N->fils->suivant->noeud; | |
62 | - N=cons_noeud(mot[i]); | |
63 | - //ajout_lettre(N,mot[i]); | |
64 | - } | |
65 | - else | |
66 | - { | |
67 | - N=N->fils->noeud; | |
68 | - N=cons_noeud(mot[i]); | |
69 | - //ajout_lettre (N,mot[i]); | |
70 | - // N=N->fils->noeud; | |
71 | - | |
72 | - } | |
73 | - | |
74 | - } | |
75 | - N->complet=1; | |
76 | - | |
48 | + printf("%s\n",mot); | |
77 | 49 | } |
78 | 50 | |
51 | +//Reprendre cette fonction! | |
79 | 52 | |
80 | -void cons_dico(FILE* fp, struct dico* D) | |
81 | -{ char a; | |
82 | - D->dernier=-1; | |
53 | +/*void cons_dico_file(FILE* fp, struct dico* D) | |
54 | +{ char mot[size]; | |
83 | 55 | if(fp==NULL) |
84 | 56 | return; |
85 | - while(fscanf(fp,"%s",&a)!=EOF) | |
86 | - { ajout_mot(D,&a); | |
87 | - D->dernier++;} | |
57 | + while(fscanf(fp,"%s",a)==1) | |
58 | + { ajout_mot(D,a); | |
59 | + //D->dernier++;} | |
88 | 60 | |
89 | -} | |
61 | + }*/ | |
90 | 62 | |
91 | -int rech_mot(struct dico D,char mot [size]) | |
63 | +/*int rech_mot(struct dico D,char mot [size]) | |
92 | 64 | { |
93 | 65 | Noeud N; |
94 | 66 | int nbre; |
... | ... | @@ -104,22 +76,22 @@ int rech_mot(struct dico D,char mot [size]) |
104 | 76 | else |
105 | 77 | nbre=0; |
106 | 78 | } |
107 | - if(N.complet==1) | |
79 | + if(N.complet==1)return newmot | |
108 | 80 | nbre=1; |
109 | 81 | } |
110 | 82 | else |
111 | 83 | nbre= 0; |
112 | 84 | } |
113 | 85 | return nbre; |
114 | -} | |
86 | + }*/ | |
115 | 87 | |
116 | 88 | |
117 | -void correction_texte(char filename[size], struct dico D) | |
89 | +/*void correction_texte(char filename[size], struct dico D) | |
118 | 90 | { |
119 | 91 | FILE *fp=fopen(filename, "r"); |
120 | 92 | char mot[size]; |
121 | 93 | int x; |
122 | - if(fp==NULL) | |
94 | + if(fp==NULL)return newmot | |
123 | 95 | return; |
124 | 96 | else |
125 | 97 | { |
... | ... | @@ -135,11 +107,13 @@ void correction_texte(char filename[size], struct dico D) |
135 | 107 | } |
136 | 108 | |
137 | 109 | |
138 | -} | |
139 | -int main(){ | |
140 | - struct dico d; | |
141 | - ajout_mot(&d,"emilie"); | |
142 | - printf( "%c",d.tableau[0].valeur); | |
143 | - return 0; | |
110 | + }*/ | |
111 | + | |
112 | +int main() | |
113 | +{ | |
114 | + char* newmot; | |
115 | + sup_lettre("emilie"); | |
116 | + | |
117 | + return 0; | |
144 | 118 | } |
145 | 119 | ... | ... |