on reprend, ca commence a etre long

master
esterfreyja 7 months ago
parent 394ec0283e
commit 84eeaf2b69

@ -15,7 +15,7 @@ OBJ=$(patsubst src/%.c,obj/%.o,$(SRC))
#edition des liens : génération de l'exécutaba partir des .o #edition des liens : génération de l'exécutaba partir des .o
bin/exe: $(OBJ) bin/exe: $(OBJ)
$(CC) $(OBJ) -o $@ $(SAN) $(CC) $(OBJ) -o $@
# génération des .a partir des .cpp et .hpporrespondants : # génération des .a partir des .cpp et .hpporrespondants :
obj/%.o: src/%.c obj/%.o: src/%.c

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -345,3 +345,56 @@ int deseq(Arbre a)
return 0; return 0;
return h(ag(a)) - h(ad(a)); return h(ag(a)) - h(ad(a));
} }
Arbre insr(Arbre a, int x)
{
Couple c;
c = couper(a, x);
return reeq(e(c.c1, x, c.c2));
}
Couple couper(Arbre a, int x)
{
Couple c;
Couple d;
if(vide(a))
{
c.c1 = arbreNouv();
c.c2 = arbreNouv();
return c;
}
if(x == r(a))
{
c.c1 = ag(a);
c.c2 = ad(a);
return c;
}
if(x < r(a))
{
d = couper(ag(a), x);
c.c1 = d.c1;
c.c2 = e(d.c2, r(a), ad(a));
return c;
}
d = couper(ad(a), x);
c.c1 = e(ag(a), r(a), d.c1);
c.c2 = d.c2;
return c;
}
Arbre oterMin(Arbre a)
{
Arbre tmp;
if(vide(a))
return a;
if(vide(ag(a)))
{
tmp = ad(a);
free(a);
return tmp;
}
a->g = oterMin(a->g);
return a;
}

@ -7,33 +7,42 @@ typedef struct maillon
int v; int v;
} Maillon, *Arbre; } Maillon, *Arbre;
Arbre arbreNouv(void); typedef struct
bool vide(Arbre a); {
void afficherRacine(int v, int k); Arbre c1;
Arbre e(Arbre a, int x, Arbre b); Arbre c2;
void afficherArbre(Arbre a); } Couple;
void afficherArb(Arbre a, int k);
Arbre ag(Arbre a); Arbre arbreNouv(void);//
Arbre ad(Arbre a); bool vide(Arbre a);//
int r(Arbre a); void afficherRacine(int v, int k);//
int max(int a, int b); Arbre e(Arbre a, int x, Arbre b);//
int nn(Arbre a); void afficherArbre(Arbre a);//
bool f(Arbre a); void afficherArb(Arbre a, int k);//
int nf(Arbre a); Arbre ag(Arbre a);//
Arbre eg(Arbre a); Arbre ad(Arbre a);//
Arbre ed(Arbre a); int r(Arbre a);//
int h(Arbre a); int max(int a, int b);//
void viderArbre(Arbre a); int nn(Arbre a);//
int nn(Arbre a); bool f(Arbre a);//
bool egarb(Arbre a, Arbre b); int nf(Arbre a);//
Arbre insf(Arbre a, int x); Arbre eg(Arbre a);//
Arbre supp(Arbre a, int x); Arbre ed(Arbre a);//
Arbre oterMax(Arbre a); int h(Arbre a);//
Arbre rech(Arbre a, int x); void viderArbre(Arbre a);//
bool trie(Arbre a); int nn(Arbre a);//
Arbre rd(Arbre a); bool egarb(Arbre a, Arbre b);//
Arbre rg(Arbre a); Arbre insf(Arbre a, int x);//
Arbre rgd(Arbre a); Arbre supp(Arbre a, int x);//
Arbre rdg(Arbre a); Arbre oterMax(Arbre a);//
Arbre reeq(Arbre a); Arbre rech(Arbre a, int x);//
int deseq(Arbre a); bool trie(Arbre a);//
Arbre rd(Arbre a);//
Arbre rg(Arbre a);//
Arbre rgd(Arbre a);//
Arbre rdg(Arbre a);//
Arbre reeq(Arbre a);//
int deseq(Arbre a);//
Arbre insr(Arbre a, int x);//
Couple couper(Arbre a, int x);//
Arbre oterMin(Arbre a);//

@ -31,15 +31,16 @@ void testTri(bool a)
int main(void) int main(void)
{ {
Arbre Arbre1 = arbreNouv(); Arbre Arbre1 = arbreNouv();
Arbre1 = insf(Arbre1, 5); Arbre1 = insf(Arbre1, 11);
Arbre1 = insf(Arbre1, 6);
Arbre1 = insf(Arbre1, 7);
/*Arbre1 = insf(Arbre1, 8);
Arbre1 = insf(Arbre1, 9);
Arbre1 = insf(Arbre1, 10); Arbre1 = insf(Arbre1, 10);
Arbre1 = insf(Arbre1, 12);*/ Arbre1 = insf(Arbre1, 9);
Arbre1 = insf(Arbre1, 8);
Arbre1 = insf(Arbre1, 7);
Arbre1 = insf(Arbre1, 6);
Arbre1 = insf(Arbre1, 5);
afficherArbre(Arbre1);
oterMin(Arbre1);
afficherArbre(Arbre1); afficherArbre(Arbre1);
testTri(trie(Arbre1));
viderArbre(Arbre1); viderArbre(Arbre1);
return 0; return 0;
} }

@ -15,7 +15,7 @@ OBJ=$(patsubst src/%.c,obj/%.o,$(SRC))
#edition des liens : génération de l'exécutaba partir des .o #edition des liens : génération de l'exécutaba partir des .o
bin/exe: $(OBJ) bin/exe: $(OBJ)
$(CC) $(OBJ) -o $@ $(SAN) $(CC) $(OBJ) -o $@ #$(SAN)
# génération des .a partir des .cpp et .hpporrespondants : # génération des .a partir des .cpp et .hpporrespondants :
obj/%.o: src/%.c obj/%.o: src/%.c

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -33,7 +33,7 @@ void testGraphe()
g = adjs(g, 3); g = adjs(g, 3);
g = adjs(g, 6); g = adjs(g, 6);
// g = adjs(g, 3); marche pas (normal) g = adjs(g, 3);
g = adjs(g, 9); g = adjs(g, 9);
g = adjs(g, 8); g = adjs(g, 8);
g = adjs(g, 15); g = adjs(g, 15);
@ -52,19 +52,18 @@ void testGraphe()
g = adja(g, 9, 6); g = adja(g, 9, 6);
g = adja(g, 9, 15); g = adja(g, 9, 15);
g = adja(g, 23, 15); g = adja(g, 23, 15);
// Test existe if(exa(g, 3, 5))
// if(exa(g, 3, 5)) printf("exa marche pas\n");
// printf("exa marche pas\n"); else
// else printf("exa marche\n");
// printf("exa marche\n"); if(exa(g, 3, 6))
// if(exa(g, 3, 6)) printf("exa marche\n");
// printf("exa marche\n"); else
// else printf("exa marche pas\n");
// printf("exa marche pas\n");
afficherGraphe(g); afficherGraphe(g);
g = supa(g, 9, 6); g = supa(g, 9, 6);
afficherGraphe(g); afficherGraphe(g);
// g = sups(g, 15); fonctionne pas (normal) g = sups(g, 15);
g = supa(g, 3, 6); g = supa(g, 3, 6);
g = sups(g, 3); g = sups(g, 3);
afficherGraphe(g); afficherGraphe(g);

Loading…
Cancel
Save