Verification

Fermé
soleil bogie Messages postés 2 Date d'inscription vendredi 23 avril 2010 Statut Membre Dernière intervention 15 mai 2010 - 15 mai 2010 à 11:18
Bonjour,
qui me aider pour cette probleme cannot execute where is the probleme pluuuuuuuuuuuuuuuus
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct arbre_ {
char *mot;
struct arbre_ * fd;
struct arbre_ * fg;
} *arbre;

/********************************/
arbre vide();
arbre creer_noeud (char* mo);
void insertion (arbre* d,char* mot,char* mo);
arbre fd (arbre d);
arbre fg (arbre d);
char feuille (arbre d);
char nb_noeud (arbre d);
void parcours_prefixe (arbre d);
void parcours_infixe (arbre d);
void parcours_suffixe (arbre d);
/*****creer arbre vide********/
arbre vide()
{
return NULL;
}
/*******creer un noeud**************/
arbre creer_noeud (char* mo)
{
arbre p = (arbre) malloc ( sizeof ( struct arbre_) );
strcpy(mo,mo);
p->fd = NULL;
p->fg = NULL;
return p;
}
/***********inssertion ******************/
void insertion (arbre *d,char* mo)
{
int i = 0;
arbre p = creer_noeud (mo);
arbre e;
if (* d == NULL)
* d = p;
else
{
e = * d;
if (p->mot == e->mot)
printf("Impossible d'inserer");
if (e != NULL)
{
if (p->mot > e->mot)
{
if (e->fd != NULL)
insertion (&(e->fd),mo);
else
{
e->fd = p;
p = * d;
i++;
}
}
else
{
if (e->fg != NULL)
insertion (&(e->fg),mo);
else
{
e->fg = p;
p = * d;
i++;
}
}
}
if (i == 0)
{
if (p->mot > e->mot)
{
e->fd = p;
p = * d;
}
else
{
e->fg = p;
p = * d;
}
}
}
}
//====================foction qui recherche un element de remplacer==========//
void remplacer(arbre d){
arbre q,r=d;
if (r->fd!=NULL)
{ remplacer(r->fd);
}
else
{
q->mot=r->mot;
q=r;
r=r->fg;
}
}
//======================fonction qui suppremer un element dans la liste=======//
void supremer(arbre& p,char* mo)
{
int trouve; arbre n;
arbre m=p;
if(m==NULL)
{trouve=0; }
else
{
if(m->mot>mo)
{
supremer((m->fg),mo);
}
else
{
if(m->mot<mo)
{
supremer((m->fd),mo);
}
else
{
trouve=1;
n=m;
if(m->fd==NULL)
{
m=m->fg;
}
else
{
if(m->fg==NULL)
{
m=m->fd;
}
else
{
remplacer(m->fg);
}
}
}
}
}
}
/********************************/
arbre fd (arbre d)
{
return d->fd;
}
/********************************/
arbre fg (arbre d)
{
return d->fg;
}
/********************************/
char feuille (arbre d)
{
return ((!fd(d))&&(!fg (d)));
}
/********************************/
char nb_noeud (arbre d)
{
if (d == NULL)
return 0;
else
return (1+nb_noeud (d->fd)+nb_noeud (d->fg));
}
/********************************/
void parcours_prefixe (arbre d)
{
if (d != NULL)
{
printf("%d\n",d->mot);
parcours_prefixe (d->fg);
parcours_prefixe (d->fd);
}
}
/********************************/
void parcours_infixe (arbre d)
{
if (d != NULL)
{
parcours_infixe (d->fg);
printf("%d\n",d->mot);
parcours_infixe (d->fd);
}
}
/********************************/
void parcours_suffixe (arbre d)
{
if (d != NULL)
{
parcours_infixe (d->fg);
parcours_infixe (d->fd);
printf("%d\n",d->mot);
}
}
//******//
pile choix_utilisateur()
{
arbre p;
char* x;
int i = 0;
printf("Donner la taille de la arbre = ");
scanf("%d",&x);
p = creer_noeud (x);
while (i != 3)
{
printf(" /*************************/\n");
printf("Pour insertion tapez 1\n");
printf("Pour supremer tapez 2\n");
printf("Pour sortir tapez 3\n");
printf("Choix = ");
scanf("%d",&i);
if (i == 1)
{
printf ("Donner une mot a inserer = ");
scanf("%d",&x);
insertion (&p,x);
}
if (i == 2)
{
supprition(&p,x);
}
printf(" /*************************/\n");
printf(" arbre aprés traitement\n");
printf(" /*************************/\n");
parcours_suffixe(p);
parcours_infixe(p);
parcours_prefixe(p);
}
return p;
}
/************************************/


void main()
{
arbre a = vide ();
a = creer_noeud (1);
a->fg = creer_noeud (2);
a->fd = creer_noeud (3);
parcours_suffixe (a);
{
arbre l = choix_utilisateur ();
/*arbre * f = fopen ("fichier de pile.txt","w+");
if (f == NULL)
printf("Fichier vide");
else
{
for (j = 0; j <= l.sommet; j++)
{
sprintf (q,"%d",l.tab[j]);
fprintf(f,"%s",q);
fprintf(f,"%s","\n");
}
}
return 0;*/
}
}