Commit 7197538bdecac25f48215ddede0ab0f4b87cf42d
1 parent
9b8beaf2
Projet modifié
Showing
1 changed file
with
51 additions
and
1 deletions
Show diff stats
correcteur.c
1 | -hello world | 1 | +#include <stdio.h> |
2 | +#include <stdlib.h> | ||
3 | +#include <stdbool.h> | ||
4 | + | ||
5 | +#DEFINE MAX_LETTRES 30 | ||
6 | + | ||
7 | + | ||
8 | +typedef struct node { | ||
9 | + struct node * lettres[27]; | ||
10 | + bool fin_de_mot; | ||
11 | + int dernier; | ||
12 | +} Node; | ||
13 | + | ||
14 | + | ||
15 | +void ajout_tete(Node **N, char * mot) | ||
16 | +{ | ||
17 | + Cellule *nouveau = malloc(sizeof(struct node)); | ||
18 | + strcpy(nouveau->(*N)->dernier, mot); | ||
19 | + nouveau->suivant = *N; | ||
20 | + *N = nouveau; | ||
21 | +} | ||
22 | + | ||
23 | + | ||
24 | +void ajout_alphab(Node ** pn, char * mot) | ||
25 | +{ | ||
26 | + if (*pn == NULL) | ||
27 | + { | ||
28 | + ajout_tete(pn,mot); | ||
29 | + } | ||
30 | + else | ||
31 | + { | ||
32 | + if (strcmp(mot, (*pn)->valeur) != 0) | ||
33 | + { | ||
34 | + ajout_alphab(pn[((*pn)->dernier)+1],mot); | ||
35 | + (*pn)->dernier ++; | ||
36 | + } | ||
37 | + } | ||
38 | +} | ||
39 | + | ||
40 | + | ||
41 | +Node * charger_arbre(){ | ||
42 | + File * dico; | ||
43 | + char mot[MAX_LETTRES]; | ||
44 | + *dico = fopen("words.txt",'r'); | ||
45 | + while (fscanf(dico,"%s",mot) == 1){ | ||
46 | + ajout_alphab(Arbre,mot); | ||
47 | + } | ||
48 | + fclose(); | ||
49 | + return Arbre; | ||
50 | +} | ||
51 | + |