#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
struct noeud
{
struct noeud *gauche;
int info;
struct noeud *droite;
};
typedef struct noeud *pnoeud;
pnoeud arbre = NULL;
pnoeud maketree (int x)
{
pnoeud nouveau;
nouveau = new noeud;
nouveau -> gauche =NULL;
nouveau -> info = x;
nouveau -> droite = NULL;
return nouveau;
}
void setgauche (int x, pnoeud p)
{
if (p == NULL)
{
cout<<"insertion impossible";
getch ();
exit (0);
}
if (p -> gauche != NULL)
{
cout <<"insertion impossible";
getch ();
exit (0);
}
p -> gauche = maketree (x);
}
void setdroite (int x, pnoeud p)
{
if (p == NULL)
{
cout <<"insertion impossible";
getch ();
exit (0);
}
if (p -> droite != NULL)
{
cout <<"insertion impossible";
getch ();
exit (0);
}
p -> droite = maketree (x);
}
void intrav (pnoeud p)
{
if (p == NULL)
{
cout <<"rien a afficher";
getch ();
exit (0);
}
intrav (p -> gauche);
cout << p -> info<< endl;
intrav (p -> droite);
}
void main (void)
{
int x, n;
cout <<"entrer le nombre d'elements";
cin >>n;
cout <<"entrer un entier \n";
cin >>x;
arbre = maketree(x);
pnoeud p, q;
for (int i=0; i<n; i++)
{
cout <<"entrer un entier \n";
cin >> x;
p = q = arbre;
....
}
merci!