ProjetS6.c
1.32 KB
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
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include "listechaines.j"
typedef struct node {
char lettre;
bool fdm;
struct node *fils_suiv;
struct node *frere_suiv;
}Node, *PtNode, *Tree;
void ajout_tete(Node * pl, char lettre) {
PtNode ptr = malloc(sizeof(*ptr));
strcpy(ptr->lettre,lettre);
ptr->frere_suiv = *pl;
*pl = ptr;
}
bool est_present(char lettre; struct node *tree) {
while(tree->frere_suiv)!=NULL) {
if (lettre == (tree->lettre)) {
return true;
}
return false;
}
void cons_tree(struct node ** ptr_tree, char lettre, struct node *fils_suiv, struct node *frere_suiv)
{
*ptr_tree = malloc(sizeof(struct node));
(*ptr_tree)->lettre=lettre;
(*ptr_tree)->fils_suiv=fils_suiv;
(*ptr_tree)->frere_suiv=frere_suiv;
}
/*void ajouter_mot(struct node ** ptr_tree, char *mot) {
int i =0;
int etage=1;
if (*ptr_tree == NULL) {
cons_tree(ptr_tree,mot[i],NULL,NULL);
etage++;
return;
}
while (mot[i]!= NULL) {
if (est_present(mot[i],&ptr_tree) && (etage == i-1)) {
i++;
continue;
} else {ajout_tete(&ptr_tree,mot[i])}
i++;
}
*/
}
void charger_dicho() {}
void afficher_arbre() {}
void free_tree() {}