c8dbffe1
Raouak Haroun
second commit
|
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
int valeur;
struct noeud *gauche;
struct noeud *droite;
} noeud ;
void print_arbre(noeud *arbre)
{
if (arbre==NULL)
printf("NULL\n");
else if(arbre!=NULL)
{
printf("%d\n",arbre->valeur);
if (arbre->gauche != NULL)
print_arbre(arbre->gauche);
// printf("\n");}
else if(arbre->gauche == NULL)
printf("NULL\t");
if (arbre->droite != NULL)
print_arbre(arbre->droite);
// printf("\n");}
else if (arbre->droite != NULL)
printf("NULL\t");
}
}
void insertion(noeud ** arbre, int v){
if (*arbre==NULL) /* si le noeud n’existe pas, on le crée */
{
*arbre=(noeud*) malloc(sizeof(noeud));
(*arbre)->valeur=v;
(*arbre)->gauche=NULL;
(*arbre)->droite=NULL;
}
}
// else
// {
// if (v>(*arbre)->valeur)
void insertionD(noeud ** arbre, int v){
insertion(&(*arbre)->droite,v); /* aller a droite */ }
// else
void insertionG(noeud ** arbre, int v){
insertion(&(*arbre)->gauche,v); /* aller a gauche */ }
int main(){
noeud *Arbre = NULL;
insertion(&Arbre, 303);
insertionD(&Arbre, 304);
insertionG(&Arbre, 305);
print_arbre(Arbre);
// FILE* fichier = NULL;
//fichier = fopen("texte.txt","r");
return 0;
}
|