Commit 8920d8f12df136f959ab2075f4d6c5afe262f6a4
1 parent
febc0130
update projet0.c
Showing
1 changed file
with
26 additions
and
7 deletions
Show diff stats
projet0.c
... | ... | @@ -5,12 +5,12 @@ |
5 | 5 | |
6 | 6 | struct node { |
7 | 7 | char lettre; |
8 | - struct cell* listeLettre; | |
8 | + struct cell* listeFils; | |
9 | 9 | }; |
10 | 10 | |
11 | 11 | struct cell { |
12 | 12 | struct node* arbre; |
13 | - struct cell* suivant; | |
13 | + struct cell* arbreSuivant; | |
14 | 14 | }; |
15 | 15 | |
16 | 16 | void initialisation_tab_arbre(struct node tab[]) { |
... | ... | @@ -31,9 +31,12 @@ void ajout_tete(char elem, struct cell** pL) { |
31 | 31 | *pL = p; |
32 | 32 | } |
33 | 33 | |
34 | -void insertion(char elem, struct cell** pL) { | |
35 | - if((*pL == NULL)||((*pL)->arbre->lettre > elem)) ajout_tete(elem, pL); | |
36 | - else if((*pL)->arbre->lettre == elem) return; | |
34 | +struct cell* insertion(char elem, struct cell** pL) { | |
35 | + if((*pL == NULL)||((*pL)->arbre->lettre > elem)) { | |
36 | + ajout_tete(elem, pL); | |
37 | + return (*pL)->arbre->listeFils; | |
38 | + } | |
39 | + else if((*pL)->arbre->lettre == elem) return (*pL)->arbre->listeFils; | |
37 | 40 | else insertion(elem, &(*pL)->suivant); |
38 | 41 | } |
39 | 42 | |
... | ... | @@ -43,8 +46,24 @@ void insertion(char elem, struct cell** pL) { |
43 | 46 | } |
44 | 47 | }*/ |
45 | 48 | |
46 | -void lire_fichier(FILE* fd, ) { | |
47 | - | |
49 | +void lire_fichier(FILE* fd, struct node tab_arbre_prcp[]) { | |
50 | + struct cell* localisationArbre; | |
51 | + char motLu[50]; | |
52 | + int i = 0; | |
53 | + if(fd!=NULL) | |
54 | + { | |
55 | + while(fscanf(fd, "%s", motLu)==1) | |
56 | + { | |
57 | + if((caracLu[i] >= a) && (caracLu[i] <= z)) localisationArbre = tab_arbre_prcp[motLu[0]-97].listeFils; | |
58 | + | |
59 | + if(caracLu[i] == 39) localisationArbre = tab_arbre_prcp[A].listeFils; //A = derniere case du tab | |
60 | + while(motLu[i] != '\0') | |
61 | + { | |
62 | + i += 1; | |
63 | + localisationArbre = insertion(caracLu[i], tab_arbre_prcp[motlu[0]-97]); | |
64 | + } | |
65 | + | |
66 | + | |
48 | 67 | } |
49 | 68 | |
50 | 69 | int main(int argc, char* argv[]) { | ... | ... |