Commit 4f23ebd6cc3e5be601401867eee8a29a3c0a9849

Authored by tvieuble
1 parent cf601bd2

Suppression fichiers inutiles

Showing 1 changed file with 0 additions and 179 deletions   Show diff stats
projetfinal.c deleted
... ... @@ -1,179 +0,0 @@
1   -#include <stdio.h>
2   -#include <stdlib.h>
3   -
4   -#define A 26
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; i++) {
25   - tab[i].lettre = 97+i; //ajout lettres minuscules
26   - tab[i].listeFils = NULL;
27   - }
28   -}
29   -
30   -void ajout_tete(char elem, struct cell** pL) {
31   - struct cell* p;
32   - p = malloc(sizeof(struct cell));
33   - p->arbre = malloc(sizeof(struct node));
34   - p->arbre->listeFils = NULL;
35   - p->arbre->lettre = elem;
36   - p->arbreSuivant = *pL;
37   - *pL = p;
38   -}
39   -
40   -struct cell ** insertion(char elem, struct cell** pL) {
41   - if(((*pL) == NULL) || ((*pL)->arbre->lettre > elem)) {
42   - ajout_tete(elem, pL);
43   - return &(*pL)->arbre->listeFils;
44   - }
45   - else if((*pL)->arbre->lettre == elem) {
46   - return &(*pL)->arbre->listeFils;
47   - }
48   - else {
49   - return insertion(elem, &(*pL)->arbreSuivant);
50   - }
51   -}
52   -
53   -
54   -void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) {
55   -
56   - struct cell** localisationArbre = NULL;
57   - int cptmot = 0;
58   - char motLu[50];
59   - while(fscanf(fd, "%s", motLu)==1) {
60   - printf("mot lu : %s\n", motLu);
61   - int estUneLettre = 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   - else {
71   - printf("Erreur remplissage dico : L'un des caracteres n'est pas une lettre\n");
72   - printf("Mot : %s incorrect\n", motLu);
73   - estUneLettre = 0;
74   - }
75   - while((motLu[i] != '\0') && (estUneLettre == 1)) {
76   - i += 1;
77   - printf("lettre lue %d\n", motLu[i]);
78   - localisationArbre = insertion(motLu[i], localisationArbre);
79   - }
80   - }
81   - printf("\n");
82   - fclose(fd);
83   - printf("%d mots inseres dans le dictionnaire.\n", cptmot);
84   -}
85   -
86   -struct cell** test_mot(char mot, struct cell** localisation, int* verif) {
87   -
88   - if((*localisation == NULL) || (*localisation)->arbre->lettre > mot) {
89   - *verif = 0;
90   - return NULL;
91   - }
92   - if((*localisation)->arbre->lettre == mot) {
93   - return &(*localisation)->arbre->listeFils;
94   - }
95   - else {
96   - return test_mot(mot, &(*localisation)->arbreSuivant, verif);
97   - }
98   -}
99   -
100   -void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) {
101   - struct cell** localisationArbre = NULL;
102   - int verif;
103   - char motLu[50];
104   - while(fscanf(fd, "%s", motLu)==1) {
105   - verif = 1;
106   - int i = 0;
107   - if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) {
108   - localisationArbre = &tab_arbre_prcp[motLu[0]-65].listeFils;
109   - }
110   - else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) {
111   - localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils;
112   - }
113   - else {
114   - printf("Erreur correction txt : L'un des caracteres n'est pas une lettre\n");
115   - verif = 0;
116   - }
117   - while((verif == 1) && (motLu[i] != '\0')) {
118   - i += 1;
119   - localisationArbre = test_mot(motLu[i], localisationArbre, &verif);
120   - }
121   - if(verif == 0) printf("Mot %s non present dans le dicitonnaire.\n", motLu);
122   - }
123   - fclose(fd);
124   -}
125   -
126   -void correction_mot(struct node tab_arbre_prcp[]) {
127   - struct cell** localisationArbre = NULL;
128   - int verif;
129   - char motLu[50];
130   - printf("Entrez un mot ou une phrase a corriger : \n(0 pour quitter)\n");
131   - while(scanf("%s", motLu)==1) {
132   - if(motLu[0]=='0') return;
133   - verif = 1;
134   - int i = 0;
135   - if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) {
136   - localisationArbre = &tab_arbre_prcp[motLu[0]-65].listeFils;
137   - }
138   - else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) {
139   - localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils;
140   - }
141   - else {
142   - printf("Erreur correction txt : L'un des caracteres n'est pas une lettre\n");
143   - verif = 0;
144   - }
145   - while((verif == 1) && (motLu[i] != '\0')) {
146   - i += 1;
147   - printf("lettre lue %d\n", motLu[i]);
148   - localisationArbre = test_mot(motLu[i], localisationArbre, &verif);
149   - }
150   - if(verif == 0) printf("Mot : %s non present dans le dicitonnaire.\n", motLu);
151   - else printf("Mot : %s 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   - printf("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   -}