sa fongzione

master
esterfreyja 2 months ago
parent bd5961ec11
commit 5de9f34d23

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -207,27 +207,22 @@ Arbre supp(Arbre a, int x) //
if(vide(ag(a)))
{
tmp = a->d;
free(a);
return tmp;
}
if(vide(ad(a)))
{
tmp = a->g;
free(a);
return tmp;
}
tmp = e(oterMax(a->g), r(ed(a->g)), a->d);
free(a);
return tmp;
}
if(x < r(a))
{
tmp = e(supp(a->g, x), r(a), a->d);
free(a);
return tmp;
}
tmp = e(a->g, r(a), supp(a->d, x));
free(a);
return tmp;
}

@ -39,7 +39,7 @@ int main(void)
Arbre1 = insf(Arbre1, 6);
Arbre1 = insf(Arbre1, 5);
afficherArbre(Arbre1);
oterMin(Arbre1);
Arbre1 = supp(Arbre1, 10);
afficherArbre(Arbre1);
viderArbre(Arbre1);
return 0;

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -183,9 +183,9 @@ Arbre insf(Arbre a, char *x) //
{
return e(arbreNouv(), x, arbreNouv());
}
if (x == r(a))
if (my_strcmp(x, r(a)) == 0)
return a;
if (x < r(a))
if (my_strcmp(x, r(a)) < 0)
{
a->g = insf(a->g, x);
return reeq(a);
@ -200,32 +200,27 @@ Arbre supp(Arbre a, char *x) //
if(vide(a))
return a;
if(my_strcmp(x, r(a)))
if(my_strcmp(x, r(a)) == 0)
{
if(vide(ag(a)))
{
tmp = a->d;
free(a);
return tmp;
}
if(vide(ad(a)))
{
tmp = a->g;
free(a);
return tmp;
}
tmp = e(oterMax(a->g), r(ed(a->g)), a->d);
free(a);
return tmp;
}
if(my_strcmp(x, r(a)) > 0)
{
tmp = e(supp(a->g, x), r(a), a->d);
free(a);
return tmp;
}
tmp = e(a->g, r(a), supp(a->d, x));
free(a);
return tmp;
}

@ -57,7 +57,7 @@ int main(void)
else if(my_strcmp(h, "4") == 0)
{
saisie(&mot);
supp(Arbre1, mot);
Arbre1 = supp(Arbre1, mot);
afficherArbre(Arbre1);
}

Loading…
Cancel
Save