Commit 055192bbe9abe514ee94eb244d331acf5dd51a98

Authored by tvieuble
1 parent 593b14c8

Suppression fichiers inutiles

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