Commit 4d8a7bb49b08ee3b0770f79b1f953fce4be1b5ca

Authored by pvernier
2 parents ebebdccc 60787f42

Merge branch 'master' of https://archives.plil.fr/pvernier/ima3_projet_pa_2019

Makefile 0 โ†’ 100644
... ... @@ -0,0 +1,8 @@
  1 +FLAGS= -Wall -Wextra
  2 +
  3 +all : projetfinal
  4 +
  5 +projetfinal: projetfinalaccent2.o main.o
  6 + gcc -c main.c projetfinalaccent2.c $(FLAGS)
  7 +
  8 + gcc main.o projetfinalaccent2.o -o projetfinal $(FLAGS)
0 9 \ No newline at end of file
... ...
fonctions.h 0 โ†’ 100644
... ... @@ -0,0 +1,36 @@
  1 +#include <stdio.h>
  2 +#include <stdlib.h>
  3 +#include <wchar.h>
  4 +#include <locale.h>
  5 +
  6 +#define A 256
  7 +
  8 +struct node {
  9 + wchar_t lettre;
  10 + struct cell* listeFils;
  11 +};
  12 +
  13 +struct cell {
  14 + struct node* arbre;
  15 + struct cell* arbreSuivant;
  16 +};
  17 +
  18 +void ajout_tete(wchar_t, struct cell**);
  19 +
  20 +struct cell ** insertion(wchar_t, struct cell**);
  21 +
  22 +void initialisation_tab_arbre(struct node[]);
  23 +
  24 +int indice_lettre(struct node[], wchar_t);
  25 +
  26 +void remplir_dico(FILE*, struct node[]);
  27 +
  28 +struct cell ** test_mot(wchar_t, struct cell**, int*);
  29 +
  30 +void correction_txt(FILE*, struct node[]);
  31 +
  32 +void correction_mot(struct node);
  33 +
  34 +void desalocationArbre(struct cell**);
  35 +
  36 +void desalocationTableauArbre(struct node[]);
0 37 \ No newline at end of file
... ...
main.c 0 โ†’ 100644
... ... @@ -0,0 +1,35 @@
  1 +#include "fonctions.h"
  2 +
  3 +#define A 256
  4 +
  5 +int main(int argc, char* argv[]) {
  6 +
  7 +
  8 + setlocale(LC_ALL, "");
  9 + FILE* dico = NULL;
  10 + FILE* txt = NULL;
  11 + struct node tab_arbre[A];
  12 +
  13 + if(argc>2) {
  14 + dico = fopen(argv[1], "r");
  15 + txt = fopen(argv[2], "r");
  16 + }
  17 + else {
  18 + dico = NULL;
  19 + txt = NULL;
  20 + }
  21 + if ((dico == NULL) || (txt == NULL)) {
  22 + wprintf(L"Erreur : il manque un ou plusieurs fichiers !\n");
  23 + return 1;
  24 + }
  25 + initialisation_tab_arbre(tab_arbre);
  26 + remplir_dico(dico, tab_arbre);
  27 +
  28 + correction_txt(txt, tab_arbre);
  29 + correction_mot(tab_arbre);
  30 + desalocationTableauArbre(tab_arbre);
  31 +
  32 + printf("fini\n");
  33 +
  34 + return 0;
  35 +}
0 36 \ No newline at end of file
... ...
projetfinalaccent2.c
... ... @@ -3,17 +3,9 @@
3 3 #include <wchar.h>
4 4 #include <locale.h>
5 5  
6   -#define A 256
7   -
8   -struct node {
9   - wchar_t lettre;
10   - struct cell* listeFils;
11   -};
  6 +#include "fonctions.h"
12 7  
13   -struct cell {
14   - struct node* arbre;
15   - struct cell* arbreSuivant;
16   -};
  8 +#define A 256
17 9  
18 10 void ajout_tete(wchar_t elem, struct cell** pL) {
19 11 struct cell* p;
... ... @@ -48,14 +40,16 @@ void initialisation_tab_arbre(struct node tab[]) {
48 40 tab[i].lettre = '?';
49 41 tab[i+1].lettre = '!';
50 42 tab[i+2].lettre = '\'';
51   - for(int j = 0; j <= 2; j++) { //Ajout des caractรจres de ponctuation par dรฉfaut
  43 + tab[i+3].lettre = '.'; //Ajout des caractรจres de ponctuation par dรฉfau
  44 + tab[i+4].lettre = ':';
  45 + tab[i+5].lettre = ';';
  46 + for(int j = 0; j <= 5; j++) {
52 47 tab[i+j].listeFils = NULL;
53 48 insertion('\0', &(tab[i+j].listeFils));
54 49 }
55 50 }
56 51  
57   -int indice_lettre(struct node tab_arbre_prcp[], wchar_t lettre)
58   -{
  52 +int indice_lettre(struct node tab_arbre_prcp[], wchar_t lettre) {
59 53 int i = 0;
60 54 while(i >= 0 && i < A){
61 55 if(lettre == tab_arbre_prcp[i].lettre ){
... ... @@ -72,7 +66,6 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) {
72 66 int cptmot = 0, indice = 0;
73 67 wchar_t motLu[50];
74 68 while(fwscanf(fd, L"%ls", motLu)==1) {
75   - //wprintf(L"mot lu : %ls\n", motLu);
76 69 int estUneLettre = 1;
77 70 int i = 0;
78 71 cptmot += 1;
... ... @@ -135,7 +128,6 @@ void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) {
135 128 localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils;
136 129 }
137 130 else if((motLu[0] < 'A') || (motLu[0] > 'z')) {
138   - printf("jsuisla\n");
139 131 indice = indice_lettre(tab_arbre_prcp, motLu[0]);
140 132 localisationArbre = &tab_arbre_prcp[indice].listeFils;
141 133 if(indice == -1) {
... ... @@ -157,7 +149,7 @@ void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) {
157 149 cptfaute += 1;
158 150 }
159 151 }
160   - printf("Le texte comporte %d faute(s)\n", cptfaute);
  152 + wprintf(L"Le texte comporte %d faute(s)\n", cptfaute);
161 153 fclose(fd);
162 154 }
163 155  
... ... @@ -212,7 +204,7 @@ void desalocationArbre(struct cell** pL) {
212 204 free(*pL);
213 205 }
214 206  
215   -void desalocationTableauArbre(struct node tab_arbre[]){
  207 +void desalocationTableauArbre(struct node tab_arbre[]) {
216 208 int i = 0;
217 209 for(wchar_t u = 'a'; u < A; u++) {
218 210 desalocationArbre(&tab_arbre[i].listeFils);
... ... @@ -220,34 +212,3 @@ void desalocationTableauArbre(struct node tab_arbre[]){
220 212 }
221 213 }
222 214  
223   -int main(int argc, char* argv[]) {
224   -
225   -
226   - setlocale(LC_ALL, "");
227   - FILE* dico = NULL;
228   - FILE* txt = NULL;
229   - struct node tab_arbre[A];
230   -
231   - if(argc>2) {
232   - dico = fopen(argv[1], "r");
233   - txt = fopen(argv[2], "r");
234   - }
235   - else {
236   - dico = NULL;
237   - txt = NULL;
238   - }
239   - if ((dico == NULL) || (txt == NULL)) {
240   - wprintf(L"Erreur : il manque un ou plusieurs fichiers !\n");
241   - return 1;
242   - }
243   - initialisation_tab_arbre(tab_arbre);
244   - remplir_dico(dico, tab_arbre);
245   - //for(int i = 0; i < A; i++) wprintf(L"%lc\n", tab_arbre[i].lettre);
246   - correction_txt(txt, tab_arbre);
247   - correction_mot(tab_arbre);
248   - desalocationTableauArbre(tab_arbre);
249   -
250   - printf("fini\n");
251   -
252   - return 0;
253   -}
... ...
projetfinalaccent2.exe
No preview for this file type