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
|
typedef struct noeud
{
int val;
struct noeud* fg;
struct noeud* fd;
}noeud;
typedef noeud* arbre ;
void saisir_noeud(arbre *a)
{
noeud *fils1,*fils2;
int gauche,droite;
fils1=(noeud*)malloc(sizeof(*fils1));
fils2=(noeud*)malloc(sizeof(*fils2));
(*a)->fg=fils1;
(*a)->fd=fils2;
printf("donner le fils gauche de %d:",(*a)->val);
scanf("%d",&gauche);
printf("donner le fils droit de %d:",(*a)->val);
scanf("%d",&droite);
if (gauche!=0)
{
(*a)->fg->val=gauche;
saisir_noeud(&(*a)->fg);
}
if (droite!=0)
{
(*a)->fd->val=droite;
saisir_noeud(&(*a)->fd);
}
}
void affichage_post(arbre a)
{
if (a!=NULL)
{
printf("%d",a->val); //le debug mindique que ça coince ici
affichage_post(a->fg);
affichage_post(a->fd);
}
} |