-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainarbre.c
More file actions
129 lines (123 loc) · 3.04 KB
/
Copy pathmainarbre.c
File metadata and controls
129 lines (123 loc) · 3.04 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <stdio.h>
#include <stdlib.h>
#include "arbre.h"
#include "liste.h"
int menu () {
printf ("\n\n GESTION DARBRES \n\n");
printf ("\n\n ARBRES BINAIRES \n\n");
printf (" 0 - Fin du programme\n");
printf ("\n");
printf (" 1 - Creation de larbre genealogique\n");
printf (" 2 - Creation de larbre de lexpression arithmetique\n");
printf ("\n");
printf (" 3 - Parcours prefixe\n");
printf (" 4 - Parcours infixe\n");
printf (" 5 - Parcours postfixe\n");
printf ("\n");
printf ("Votre choix ? ");
int cod; scanf ("%d", &cod); getchar();
printf ("\n");
return cod;
}
int main()
{
Arbre *A2;
Arbre *A1;
int stop = 1;
Noeud *racine = cNd((char *)"Samir",
cNd((char *)"Kamal",
cNd((char *)"Yassine",
NULL,
cNd((char *)"Hind", NULL,
cF((char *)"Yasmine"))),
cNd((char *)"Sarah",
cF((char *)"Karim"),
NULL)),
NULL);
Noeud *racine1 = cNd((char *)"-", cNd((char *)"*", cNd((char *)"+",
cF((char *)"a"), cF((char *)"b")), cNd((char *)"-",
cF((char *)"c"), cF((char *)"d"))), cF((char *)"e"));
while (stop)
{
int cod = menu();
switch (cod)
{
case 0:
stop = 0;
break;
case 1:
A1 = creerArbre(racine, afficherChar, comparerInt);
break;
case 2:
A2 = creerArbre(racine1, afficherChar, comparerInt);
break;
case 3:
printf("Arbre genealogique : ");
prefixe(racine, afficherChar);
printf("\nArbre arithmetique : ");
prefixe(racine1, afficherChar);
break;
case 4:
printf("Arbre genealogique : ");
infixe(racine, afficherChar);
printf("\nArbre arithmetique : ");
infixe(racine1, afficherChar);
break;
case 5:
printf("Arbre genealogique : ");
postfixe(racine, afficherChar);
printf("\nArbre arithmetique : ");
postfixe(racine1, afficherChar);
break;
case 6:
{
printf("Trouver Noeud dans Arbre genealogique\n\n");
printf("Saisir le Noeud : ");
char trouve[20];
scanf("%s", trouve);
if (trouverNoeud(racine, trouve, comparerInt) != NULL)
{
printf("Le Noeud %s existe.",
afficher(trouverNoeud(racine, trouve, comparerInt)->reference));
}
else
{
printf("Le Noeud est introuvable.");
}
printf("\nTrouver Noeud dans Arbre arithmetique\n\n");
printf("Saisir le Noeud : ");
char trouve1[20];
scanf("%s", trouve1);
if (trouverNoeud(racine1, trouve1, comparerInt) != NULL)
{
printf("Le Noeud %s existe.",
afficher(trouverNoeud(racine1, trouve1, comparerInt)->reference));
}
else
{
printf("Le Noeud est introuvable.");
}
break;
}
case 7:
printf("Taille Arbre genealogique : ");
printf("%d", taille(racine));
printf("\nTaille Arbre arithmetique : ");
printf("%d", taille(racine1));
break;
case 8:
printf("Hauteur Arbre genealogique : ");
printf("%d", hauteur(racine));
printf("\nHauteur Arbre arithmetique : ");
printf("%d", hauteur(racine1));
break;
case 9:
printf("Arbre genealogique : ");
enLargeur(racine, afficherChar);
printf("\nArbre arithmetique : ");
enLargeur(racine1, afficherChar);
break;
}
}
return 0;
}