Commit f624d6699f4e20a450c339c3f44ccefbabbd3c5c
1 parent
d4da0378
Premier test
Showing
1 changed file
with
61 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,61 @@ |
1 | +#include <stdio.h> | |
2 | +#include <stdlib.h> | |
3 | +#include <stdbool.h> | |
4 | +#include "listechaines.j" | |
5 | + | |
6 | +typedef struct node { | |
7 | + char lettre; | |
8 | + bool fdm; | |
9 | + struct node *fils_suiv; | |
10 | + struct node *frere_suiv; | |
11 | +}Node, *PtNode, *Tree; | |
12 | + | |
13 | +void ajout_tete(Node * pl, char lettre) { | |
14 | + | |
15 | + PtNode ptr = malloc(sizeof(*ptr)); | |
16 | + strcpy(ptr->lettre,lettre); | |
17 | + ptr->frere_suiv = *pl; | |
18 | + *pl = ptr; | |
19 | + | |
20 | +} | |
21 | + | |
22 | +bool est_present(char lettre; struct node *tree) { | |
23 | + while(tree->frere_suiv)!=NULL) { | |
24 | + if (lettre == (tree->lettre)) { | |
25 | + return true; | |
26 | + } | |
27 | + return false; | |
28 | + | |
29 | +} | |
30 | + | |
31 | +void cons_tree(struct node ** ptr_tree, char lettre, struct node *fils_suiv, struct node *frere_suiv) | |
32 | +{ | |
33 | + *ptr_tree = malloc(sizeof(struct node)); | |
34 | + (*ptr_tree)->lettre=lettre; | |
35 | + (*ptr_tree)->fils_suiv=fils_suiv; | |
36 | + (*ptr_tree)->frere_suiv=frere_suiv; | |
37 | +} | |
38 | + | |
39 | +/*void ajouter_mot(struct node ** ptr_tree, char *mot) { | |
40 | + int i =0; | |
41 | + int etage=1; | |
42 | + if (*ptr_tree == NULL) { | |
43 | + cons_tree(ptr_tree,mot[i],NULL,NULL); | |
44 | + etage++; | |
45 | + return; | |
46 | + } | |
47 | + while (mot[i]!= NULL) { | |
48 | + if (est_present(mot[i],&ptr_tree) && (etage == i-1)) { | |
49 | + i++; | |
50 | + continue; | |
51 | + } else {ajout_tete(&ptr_tree,mot[i])} | |
52 | + | |
53 | + i++; | |
54 | + } | |
55 | + | |
56 | + */ | |
57 | + | |
58 | +} | |
59 | +void charger_dicho() {} | |
60 | +void afficher_arbre() {} | |
61 | +void free_tree() {} | ... | ... |