Commit aeb78bdf83f63b0662908bbe8861d4d19e391e3f
1 parent
86fcc45a
correction fin de mot
Showing
3 changed files
with
22 additions
and
6 deletions
Show diff stats
@@ -22,7 +22,7 @@ int find_mot(struct node **tab_ptr_tree,char mot[],int size,int fl) | @@ -22,7 +22,7 @@ int find_mot(struct node **tab_ptr_tree,char mot[],int size,int fl) | ||
22 | ptr_node=ptr_node->fils[k]; | 22 | ptr_node=ptr_node->fils[k]; |
23 | break; | 23 | break; |
24 | } | 24 | } |
25 | - if(k+1==ptr_node->nbr_fils)return 1; | 25 | + else if(k+1==ptr_node->nbr_fils)return 1; |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 |
@@ -2,8 +2,8 @@ | @@ -2,8 +2,8 @@ | ||
2 | 2 | ||
3 | int main() | 3 | int main() |
4 | { | 4 | { |
5 | - //FILE* fp = fopen("american-english","r"); | ||
6 | - FILE* fp = fopen("dico_test","r"); | 5 | + FILE* fp = fopen("american-english","r"); |
6 | + //FILE* fp = fopen("dico_test","r"); | ||
7 | 7 | ||
8 | if(fp == NULL) return 1 ; //File is not readable | 8 | if(fp == NULL) return 1 ; //File is not readable |
9 | 9 | ||
@@ -18,8 +18,12 @@ int main() | @@ -18,8 +18,12 @@ int main() | ||
18 | 18 | ||
19 | printf("Loading done!\n"); | 19 | printf("Loading done!\n"); |
20 | 20 | ||
21 | - char mot[] = "aaa"; | ||
22 | - int taille = 3; | 21 | + char mot[50];// = "aardvark"; |
22 | + int taille; | ||
23 | + //mot = "arabesque"; | ||
24 | + taille = 8; | ||
25 | + scanf("%s",mot); | ||
26 | + scanf("%d",&taille); | ||
23 | int result; | 27 | int result; |
24 | result = find_mot(tab,mot,taille,0); | 28 | result = find_mot(tab,mot,taille,0); |
25 | printf("%d\n",result); | 29 | printf("%d\n",result); |
@@ -37,7 +37,7 @@ void add(struct node **tab_ptr_tree, char val[],int taille, int fl) | @@ -37,7 +37,7 @@ void add(struct node **tab_ptr_tree, char val[],int taille, int fl) | ||
37 | noeudtest->nbr_fils++; | 37 | noeudtest->nbr_fils++; |
38 | noeudtest->fils = realloc(noeudtest->fils,(noeudtest->nbr_fils)*sizeof(struct node*)); | 38 | noeudtest->fils = realloc(noeudtest->fils,(noeudtest->nbr_fils)*sizeof(struct node*)); |
39 | cons_tree(&(noeudtest->fils[(noeudtest->nbr_fils)-1]),val[i]); | 39 | cons_tree(&(noeudtest->fils[(noeudtest->nbr_fils)-1]),val[i]); |
40 | - trouve = 0; | 40 | + trouve = noeudtest->nbr_fils-1; |
41 | } | 41 | } |
42 | 42 | ||
43 | noeudtest = noeudtest->fils[trouve];//on jump au noeud suivant | 43 | noeudtest = noeudtest->fils[trouve];//on jump au noeud suivant |
@@ -56,6 +56,17 @@ int size(char val[]) | @@ -56,6 +56,17 @@ int size(char val[]) | ||
56 | return cpt; | 56 | return cpt; |
57 | } | 57 | } |
58 | 58 | ||
59 | +void toLowerCase(char mot[],int size) | ||
60 | +{ | ||
61 | + for(int i=0;i<size;i++) | ||
62 | + { | ||
63 | + if(mot[i]<='Z' && mot[i]>='A') | ||
64 | + { | ||
65 | + mot[i]+=32; | ||
66 | + } | ||
67 | + } | ||
68 | +} | ||
69 | + | ||
59 | 70 | ||
60 | void load_tree(FILE *fp, struct node **tab_ptr_tree) | 71 | void load_tree(FILE *fp, struct node **tab_ptr_tree) |
61 | { | 72 | { |
@@ -65,6 +76,7 @@ void load_tree(FILE *fp, struct node **tab_ptr_tree) | @@ -65,6 +76,7 @@ void load_tree(FILE *fp, struct node **tab_ptr_tree) | ||
65 | while(fscanf(fp, "%s",val)==1) | 76 | while(fscanf(fp, "%s",val)==1) |
66 | { | 77 | { |
67 | int taille = size(val); | 78 | int taille = size(val); |
79 | + //toLowerCase(val,taille); | ||
68 | if(val[0]<97)val[0]+=32; | 80 | if(val[0]<97)val[0]+=32; |
69 | val[0]-=97; | 81 | val[0]-=97; |
70 | add(tab_ptr_tree,val,taille,(int)val[0]); | 82 | add(tab_ptr_tree,val,taille,(int)val[0]); |