Commit a65ccaaf88226156a8d2567cb1ff0408528f4af5

Authored by tvieuble
1 parent 4cdf4af3

Suppression fichiers inutiles

Showing 1 changed file with 0 additions and 179 deletions   Show diff stats
projetfinalwchar_t.cpp deleted
@@ -1,179 +0,0 @@ @@ -1,179 +0,0 @@
1 -#include <stdio.h>  
2 -#include <stdlib.h>  
3 -#include <wchar.h>  
4 -  
5 -#define A 26  
6 -  
7 -struct node {  
8 - wchar_t lettre;  
9 - struct cell* listeFils;  
10 -};  
11 -  
12 -struct cell {  
13 - struct node* arbre;  
14 - struct cell* arbreSuivant;  
15 -};  
16 -  
17 -void lien_listeFils(struct cell** pL) {  
18 - struct cell* p;  
19 - p = (struct cell*)malloc(sizeof(struct cell));  
20 -  
21 - (*pL)->arbre->listeFils = p;  
22 -}  
23 -  
24 -void initialisation_tab_arbre(struct node tab[]) {  
25 - for(int i = 0; i < A; i++) {  
26 - tab[i].lettre = 97+i; //ajout lettres minuscules  
27 - tab[i].listeFils = NULL;  
28 - }  
29 -}  
30 -  
31 -void ajout_tete(wchar_t elem, struct cell** pL) {  
32 - struct cell* p;  
33 - p = (struct cell*)malloc(sizeof(struct cell));  
34 - p->arbre = (struct node*)malloc(sizeof(struct node));  
35 - p->arbre->listeFils = NULL;  
36 - p->arbre->lettre = elem;  
37 - p->arbreSuivant = *pL;  
38 - *pL = p;  
39 -}  
40 -  
41 -struct cell ** insertion(wchar_t elem, struct cell** pL) {  
42 - if(((*pL) == NULL) || ((*pL)->arbre->lettre > elem)) {  
43 - ajout_tete(elem, pL);  
44 - return &(*pL)->arbre->listeFils;  
45 - }  
46 - else if((*pL)->arbre->lettre == elem) {  
47 - return &(*pL)->arbre->listeFils;  
48 - }  
49 - else {  
50 - return insertion(elem, &(*pL)->arbreSuivant);  
51 - }  
52 -}  
53 -  
54 -  
55 -void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) {  
56 -  
57 - struct cell** localisationArbre = NULL;  
58 - int cptmot = 0;  
59 - wchar_t motLu[50];  
60 - while(fwscanf(fd, L"%ls", motLu)==1) {  
61 - wprintf(L"mot lu : %ls\n", motLu);  
62 - int wchar_tEstUneLettre = 1;  
63 - int i = 0;  
64 - cptmot += 1;  
65 - if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) {  
66 - localisationArbre = &tab_arbre_prcp[motLu[0]-65].listeFils;  
67 - }  
68 - else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) {  
69 - localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils;  
70 - }  
71 - else {  
72 - wprintf(L"Erreur remplissage dico : L'un des caracteres n'est pas une lettre\n");  
73 - wprintf(L"Mot : %ls incorrect\n", motLu);  
74 - wchar_tEstUneLettre = 0;  
75 - }  
76 - while((motLu[i] != '\0') && (wchar_tEstUneLettre == 1)) {  
77 - i += 1;  
78 - wprintf(L"lettre lue %ld\n", motLu[i]);  
79 - localisationArbre = insertion(motLu[i], localisationArbre);  
80 - }  
81 - }  
82 - wprintf(L"\n");  
83 - fclose(fd);  
84 - wprintf(L"%d mots inseres dans le dictionnaire.\n", cptmot);  
85 -}  
86 -  
87 -struct cell** test_mot(wchar_t mot, struct cell** localisation, int* verif) {  
88 -  
89 - if((*localisation == NULL) || (*localisation)->arbre->lettre > mot) {  
90 - *verif = 0;  
91 - return NULL;  
92 - }  
93 - if((*localisation)->arbre->lettre == mot) {  
94 - return &(*localisation)->arbre->listeFils;  
95 - }  
96 - else {  
97 - return test_mot(mot, &(*localisation)->arbreSuivant, verif);  
98 - }  
99 -}  
100 -  
101 -void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) {  
102 - struct cell** localisationArbre = NULL;  
103 - int verif;  
104 - wchar_t motLu[50];  
105 - while(fwscanf(fd, L"%ls", motLu)==1) {  
106 - verif = 1;  
107 - int i = 0;  
108 - if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) {  
109 - localisationArbre = &tab_arbre_prcp[motLu[0]-65].listeFils;  
110 - }  
111 - else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) {  
112 - localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils;  
113 - }  
114 - else {  
115 - wprintf(L"Erreur correction txt : L'un des caracteres n'est pas une lettre\n");  
116 - verif = 0;  
117 - }  
118 - while((verif == 1) && (motLu[i] != '\0')) {  
119 - i += 1;  
120 - localisationArbre = test_mot(motLu[i], localisationArbre, &verif);  
121 - }  
122 - if(verif == 0) wprintf(L"Mot %ls non present dans le dicitonnaire.\n", motLu);  
123 - }  
124 - fclose(fd);  
125 -}  
126 -  
127 -void correction_mot(struct node tab_arbre_prcp[]) {  
128 - struct cell** localisationArbre = NULL;  
129 - int verif;  
130 - wchar_t motLu[50];  
131 - wprintf(L"Entrez un mot ou une phrase a corriger : \n(0 pour quitter)\n");  
132 - while(wscanf(L"%ls", motLu)==1) {  
133 - if(motLu[0]=='0') return;  
134 - verif = 1;  
135 - int i = 0;  
136 - if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) {  
137 - localisationArbre = &tab_arbre_prcp[motLu[0]-65].listeFils;  
138 - }  
139 - else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) {  
140 - localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils;  
141 - }  
142 - else {  
143 - wprintf(L"Erreur correction txt : L'un des caract%lcres n'est pas une lettre\n", 130);  
144 - verif = 0;  
145 - }  
146 - while((verif == 1) && (motLu[i] != '\0')) {  
147 - i += 1;  
148 - localisationArbre = test_mot(motLu[i], localisationArbre, &verif);  
149 - }  
150 - if(verif == 0) wprintf(L"Mot : %ls non present dans le dicitonnaire.\n", motLu);  
151 - else wprintf(L"Mot : %ls correct\n", motLu);  
152 - }  
153 -}  
154 -  
155 -  
156 -int main(int argc, char* argv[]) {  
157 - FILE* dico = NULL;  
158 - FILE* txt = NULL;  
159 - struct node tab_arbre[A];  
160 -  
161 - if(argc>2) {  
162 - dico = fopen(argv[1], "r");  
163 - txt = fopen(argv[2], "r");  
164 - }  
165 - else {  
166 - dico = NULL;  
167 - txt = NULL;  
168 - }  
169 - if ((dico == NULL) || (txt == NULL)) {  
170 - wprintf(L"Erreur : il manque un ou plusieurs fichiers !\n");  
171 - return 1;  
172 - }  
173 - initialisation_tab_arbre(tab_arbre);  
174 - remplir_dico(dico, tab_arbre); //on suppose qu'il n'y a pas d'accents dans le dictionnaire  
175 - correction_txt(txt, tab_arbre);  
176 - correction_mot(tab_arbre);  
177 -  
178 - return 0;  
179 -}