From 055192bbe9abe514ee94eb244d331acf5dd51a98 Mon Sep 17 00:00:00 2001 From: tvieuble Date: Tue, 30 Apr 2019 15:14:52 +0200 Subject: [PATCH] Suppression fichiers inutiles --- projet1.c | 193 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 0 insertions(+), 193 deletions(-) delete mode 100644 projet1.c diff --git a/projet1.c b/projet1.c deleted file mode 100644 index baa71d7..0000000 --- a/projet1.c +++ /dev/null @@ -1,193 +0,0 @@ -#include -#include - -#define A 27 - -struct node { - char lettre; - struct cell* listeFils; -}; - -struct cell { - struct node* arbre; - struct cell* arbreSuivant; -}; - -void lien_listeFils(struct cell** pL) { - struct cell* p; - p = malloc(sizeof(struct cell)); - - (*pL)->arbre->listeFils = p; -} - -void initialisation_tab_arbre(struct node tab[]) { - for(int i = 0; i < A-1; i++) { - tab[i].lettre = 97+i; //ajout lettres minuscules - tab[i].listeFils = NULL; - } - tab[A-1].lettre = 39; - tab[A-1].listeFils = NULL; -} - -void ajout_tete(char elem, struct cell** pL) { - struct cell* p; - p = malloc(sizeof(struct cell)); - p->arbre = malloc(sizeof(struct node)); - p->arbre->listeFils = NULL; - p->arbre->lettre = elem; - p->arbreSuivant = *pL; - *pL = p; -} - -struct cell ** insertion(char elem, struct cell** pL) { - if(((*pL) == NULL) || ((*pL)->arbre->lettre > elem)) { - ajout_tete(elem, pL); - return &(*pL)->arbre->listeFils; - } - else if((*pL)->arbre->lettre == elem) { - return &(*pL)->arbre->listeFils; - } - else { - return insertion(elem, &(*pL)->arbreSuivant); - } -} - - -void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { - - struct cell** localisationArbre = NULL; - int cptmot = 0; - char motLu[50]; - while(fscanf(fd, "%s", motLu)==1) { - int i = 0; - cptmot += 1; - if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) { - localisationArbre = &tab_arbre_prcp[motLu[0]-65].listeFils; - } - else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) { - localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils; - } - - else if(motLu[0] == 39) { - localisationArbre = &tab_arbre_prcp[A].listeFils; //A = derniere case du tab - } - else { - printf("Erreur remplissage dico : L'un des caractères n'est pas une lettre\n"); - return; - } - while(motLu[i] != '\0') { - i += 1; - //printf("lettre lue : %c address : %p\n", motLu[i], localisationArbre); - localisationArbre = insertion(motLu[i], localisationArbre); - //printf("tab_arbre[%d].listeFils : %p\n", i, tab_arbre_prcp[i].listeFils); - /*printf("localisationArbre.lettre : %c\n", (*localisationArbre)->arbre->lettre); - printf("localisation apres : %p\n", localisationArbre);*/ - //printf("\n"); - } - } - printf("\n"); - fclose(fd); - printf("%d mots inseres dans le dictionnaire.\n", cptmot); -} - -struct cell** test_mot(char mot, struct cell** localisation, int* verif) { - - if((*localisation == NULL) || (*localisation)->arbre->lettre > mot) { - *verif = 0; - return NULL; - } - if((*localisation)->arbre->lettre == mot) { - return &(*localisation)->arbre->listeFils; - } - else { - return test_mot(mot, &(*localisation)->arbreSuivant, verif); - } -} - -void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) { - struct cell** localisationArbre = NULL; - int verif; - char motLu[50]; - while(fscanf(fd, "%s", motLu)==1) { - verif = 1; - int i = 0; - if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) { - localisationArbre = &tab_arbre_prcp[motLu[0]-65].listeFils; - } - else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) { - localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils; - } - - else if(motLu[0] == 39) { - localisationArbre = &tab_arbre_prcp[A].listeFils; //A = derniere case du tab - } - else { - printf("Erreur correction txt : L'un des caractères n'est pas une lettre\n"); - return; - } - while((verif == 1) && (motLu[i] != '\0')) { - i += 1; - localisationArbre = test_mot(motLu[i], localisationArbre, &verif); - } - if(verif == 0) printf("Mot %s non present dans le dicitonnaire.\n", motLu); - } - fclose(fd); -} - -void correction_mot(struct node tab_arbre_prcp[]) { - struct cell** localisationArbre = NULL; - int verif; - char motLu[50]; - printf("Entrez un mot ou une phrase a corriger : \n(0 pour quitter)\n"); - while(scanf("%s", motLu)==1) { - if(motLu[0]=='0') return; - verif = 1; - int i = 0; - if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) { - localisationArbre = &tab_arbre_prcp[motLu[0]-65].listeFils; - } - else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) { - localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils; - } - - else if(motLu[0] == 39) { - localisationArbre = &tab_arbre_prcp[A].listeFils; //A = derniere case du tab - } - else { - printf("Erreur correction txt : L'un des caractères n'est pas une lettre\n"); - return; - } - while((verif == 1) && (motLu[i] != '\0')) { - i += 1; - localisationArbre = test_mot(motLu[i], localisationArbre, &verif); - } - if(verif == 0) printf("Mot : %s non present dans le dicitonnaire.\n", motLu); - else printf("Mot : %s correct\n", motLu); - } -} - - -int main(int argc, char* argv[]) { - FILE* dico = NULL; - FILE* txt = NULL; - struct node tab_arbre[A]; - - if(argc>2) { - dico = fopen(argv[1], "r"); - txt = fopen(argv[2], "r"); - } - else { - dico = NULL; - txt = NULL; - } - if ((dico == NULL) || (txt == NULL)) { - printf("Erreur : il manque un ou plusieurs fichiers !\n"); - return 1; - } - initialisation_tab_arbre(tab_arbre); - remplir_dico(dico, tab_arbre); //on suppose qu'il n'y a pas d'accents dans le dictionnaire - correction_txt(txt, tab_arbre); // correction d'un fichier texte - correction_mot(tab_arbre); // correction d'un mot ou d'une phrase entrée par l'utilisateur - - return 0; -} -- libgit2 0.21.2