From 7197538bdecac25f48215ddede0ab0f4b87cf42d Mon Sep 17 00:00:00 2001 From: Maxime Claudel Date: Mon, 25 Mar 2019 15:49:02 +0100 Subject: [PATCH] Projet modifié --- correcteur.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/correcteur.c b/correcteur.c index 3b18e51..ddc5006 100644 --- a/correcteur.c +++ b/correcteur.c @@ -1 +1,51 @@ -hello world +#include +#include +#include + +#DEFINE MAX_LETTRES 30 + + +typedef struct node { + struct node * lettres[27]; + bool fin_de_mot; + int dernier; +} Node; + + +void ajout_tete(Node **N, char * mot) +{ + Cellule *nouveau = malloc(sizeof(struct node)); + strcpy(nouveau->(*N)->dernier, mot); + nouveau->suivant = *N; + *N = nouveau; +} + + +void ajout_alphab(Node ** pn, char * mot) +{ + if (*pn == NULL) + { + ajout_tete(pn,mot); + } + else + { + if (strcmp(mot, (*pn)->valeur) != 0) + { + ajout_alphab(pn[((*pn)->dernier)+1],mot); + (*pn)->dernier ++; + } + } +} + + +Node * charger_arbre(){ + File * dico; + char mot[MAX_LETTRES]; + *dico = fopen("words.txt",'r'); + while (fscanf(dico,"%s",mot) == 1){ + ajout_alphab(Arbre,mot); + } + fclose(); + return Arbre; +} + -- libgit2 0.21.2