correcteur.c
816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#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;
}