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
|
//ma structure
typedef struct s_noeud {
char *op;
double nb;
struct s_noeud *fg,*fd;
}noeud,*arbre;
//fonction qui ajoute l'élément
arbre enrac(arbre a,char *x)
{
if (a->op==NULL)
{
a->op=x;
a->fg=NULL;
a->fd=NULL;
return a;
}
if (a->fg==NULL)
{
a->fg=enrac(a->fg,x);
return a->fg;
}
if( a->fd==NULL)
{
a->fd=enrac(a->fd,x);
return a;
}
}
//la boucle qui me permet de créer l'arbre
while( bout != NULL )
{
a=enrac(a,bout);
bout = strtok(NULL, espace);
} |
Partager