Commit 89b9e3f8b4d1a3e27217b04f21988340300b33ea

Authored by Thorsieger
1 parent 284154ca

découpage d'un texte

Showing 3 changed files with 16 additions and 16 deletions   Show diff stats
1 -A  
2 -ba  
3 -aa'  
4 -abc  
5 -c  
6 -d'  
7 -aé  
8 \ No newline at end of file 1 \ No newline at end of file
  2 +Il est l'acteur-phare de l'émission télévisée humoristique Serviteur du peuple. Sans aucune expérience politique, il se présente pour le parti homonyme à l’élection présidentielle de 2019, qu'il remporte au second tour avec 73,2 % des voix, face au chef de l'État sortant, Petro Porochenko. À 41 ans, il est le plus jeune président élu en Ukraine.
  3 +test
9 \ No newline at end of file 4 \ No newline at end of file
@@ -25,7 +25,7 @@ int main() @@ -25,7 +25,7 @@ int main()
25 wscanf(L"%ls",mot); 25 wscanf(L"%ls",mot);
26 wscanf(L"%d",&taille); 26 wscanf(L"%d",&taille);
27 int result; 27 int result;
28 - result = find_mot(tab,mot,taille,0); 28 + result = find_mot(tab,mot,taille,(int)mot[0]-97);
29 printf("%d\n",result); 29 printf("%d\n",result);
30 30
31 31
@@ -56,9 +56,9 @@ int size(wchar_t val[]) @@ -56,9 +56,9 @@ int size(wchar_t val[])
56 return cpt; 56 return cpt;
57 } 57 }
58 58
59 -void toLowerCase(wchar_t mot[],int size) 59 +void toLowerCase(wchar_t mot[])
60 { 60 {
61 - for(int i=0;i<size;i++) 61 + for(int i=0;i<size(mot);i++)
62 { 62 {
63 if(mot[i]<='Z' && mot[i]>='A') 63 if(mot[i]<='Z' && mot[i]>='A')
64 { 64 {
@@ -67,6 +67,15 @@ void toLowerCase(wchar_t mot[],int size) @@ -67,6 +67,15 @@ void toLowerCase(wchar_t mot[],int size)
67 } 67 }
68 } 68 }
69 69
  70 +void splitcarac(struct node **tab_ptr_tree,wchar_t message[])
  71 +{
  72 + if(message[0]<'a' || message[0]>'z')return;
  73 +
  74 + wchar_t *buffer;
  75 + wchar_t *token = wcstok(message, L" ,?;.:/!*+\\\"()=", &buffer);
  76 + add(tab_ptr_tree,token,size(token),(int)message[0]-97);
  77 + if(buffer!=NULL)splitcarac(tab_ptr_tree,buffer);
  78 +}
70 79
71 void load_tree(FILE *fp, struct node **tab_ptr_tree) 80 void load_tree(FILE *fp, struct node **tab_ptr_tree)
72 { 81 {
@@ -75,12 +84,8 @@ void load_tree(FILE *fp, struct node **tab_ptr_tree) @@ -75,12 +84,8 @@ void load_tree(FILE *fp, struct node **tab_ptr_tree)
75 84
76 while(fwscanf(fp, L"%ls",val)==1) 85 while(fwscanf(fp, L"%ls",val)==1)
77 { 86 {
78 - int taille = size(val);  
79 - toLowerCase(val,taille);  
80 - if(val[0]<'a' || val[0]>'z')continue;  
81 - //if(val[0]<97)val[0]+=32;  
82 - //val[0]-=97;  
83 - add(tab_ptr_tree,val,taille,(int)val[0]-97); 87 + toLowerCase(val);
  88 + splitcarac(tab_ptr_tree,val);
84 } 89 }
85 90
86 //On peut tester la bonne ou mauvaise terminaison de la lecture 91 //On peut tester la bonne ou mauvaise terminaison de la lecture