parent
68e37ae984
commit
006e2ca09e
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,13 +1,45 @@
|
|||||||
#include "arbre.h"
|
#include "arbre.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void testEg(bool a)
|
||||||
|
{
|
||||||
|
if(a)
|
||||||
|
printf("EgArb ok\n");
|
||||||
|
else
|
||||||
|
printf("EgArb nope\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void testFeuille(bool a)
|
||||||
|
{
|
||||||
|
if(a)
|
||||||
|
printf("c'est une feuille\n");
|
||||||
|
else
|
||||||
|
printf("c'est un baobab\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void testTri(bool a)
|
||||||
|
{
|
||||||
|
if(a)
|
||||||
|
printf("arbre trié\n");
|
||||||
|
else
|
||||||
|
printf("arbre non trié\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
Arbre Arbre1 = arbreNouv();
|
Arbre Arbre1 = arbreNouv();
|
||||||
Arbre Arbre2 = arbreNouv();
|
Arbre1 = insf(Arbre1, 5);
|
||||||
|
Arbre1 = insf(Arbre1, 6);
|
||||||
Arbre Arbre3 = e(Arbre1, 5, Arbre2);
|
Arbre1 = insf(Arbre1, 7);
|
||||||
afficherArbre(Arbre3);
|
/*Arbre1 = insf(Arbre1, 8);
|
||||||
viderArbre(Arbre3);
|
Arbre1 = insf(Arbre1, 9);
|
||||||
|
Arbre1 = insf(Arbre1, 10);
|
||||||
|
Arbre1 = insf(Arbre1, 12);*/
|
||||||
|
afficherArbre(Arbre1);
|
||||||
|
testTri(trie(Arbre1));
|
||||||
|
viderArbre(Arbre1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,115 @@
|
|||||||
|
#include "graph.h"
|
||||||
|
|
||||||
|
Liste listenouv(void)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool videList(Liste l)
|
||||||
|
{
|
||||||
|
return l == NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Liste insTList(Liste l, int x)
|
||||||
|
{
|
||||||
|
Maillon* maill;
|
||||||
|
|
||||||
|
maill = (Maillon*)malloc(sizeof(Maillon));
|
||||||
|
if(maill == NULL)
|
||||||
|
{
|
||||||
|
printf("Pb malloc\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
maill->v = x;
|
||||||
|
maill->suiv = l;
|
||||||
|
return maill;
|
||||||
|
}
|
||||||
|
|
||||||
|
Liste insList(Liste l, int x)
|
||||||
|
{
|
||||||
|
if(videList(l))
|
||||||
|
return insTList(l, x);
|
||||||
|
if(x < l->v)
|
||||||
|
return insTList(l,x);
|
||||||
|
if(x == l->v)
|
||||||
|
return l;
|
||||||
|
l->suiv = insList(l->suiv, x);
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
Liste supTList(Liste l)
|
||||||
|
{
|
||||||
|
Maillon* aux;
|
||||||
|
|
||||||
|
if(videList(l))
|
||||||
|
{
|
||||||
|
printf("Opération interdite\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
aux = l;
|
||||||
|
l = l->suiv;
|
||||||
|
free(aux);
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
Liste supList(Liste l, int x)
|
||||||
|
{
|
||||||
|
if(videList(l))
|
||||||
|
return l;
|
||||||
|
if(x < l->v)
|
||||||
|
return l;
|
||||||
|
if(x == l->v)
|
||||||
|
return supTList(l);
|
||||||
|
l->suiv = supList(l->suiv, x);
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tList(Liste l)
|
||||||
|
{
|
||||||
|
if(videList(l))
|
||||||
|
{
|
||||||
|
printf("Opération interdite\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
return l->v;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rechList(Liste l, int x)
|
||||||
|
{
|
||||||
|
if(videList(l))
|
||||||
|
return false;
|
||||||
|
if(x < l->v)
|
||||||
|
return false;
|
||||||
|
if(x == l->v)
|
||||||
|
return true;
|
||||||
|
return rechList(l->suiv, x);
|
||||||
|
}
|
||||||
|
|
||||||
|
int lgList(Liste l)
|
||||||
|
{
|
||||||
|
if(videList(l))
|
||||||
|
return 0;
|
||||||
|
return 1 + lgList(l->suiv);
|
||||||
|
}
|
||||||
|
|
||||||
|
Liste addQList(Liste l, int x)
|
||||||
|
{
|
||||||
|
if(videList(l))
|
||||||
|
return insTList(l,x);
|
||||||
|
l->suiv = addQList(l->suiv, x);
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
void afficherList(Liste l)
|
||||||
|
{
|
||||||
|
if(videList(l))
|
||||||
|
{
|
||||||
|
printf("\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
printf("%d\n", l->v);
|
||||||
|
afficherList(l->suiv);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
|||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct maillon
|
||||||
|
{
|
||||||
|
int v;
|
||||||
|
struct maillon *suiv;
|
||||||
|
} Maillon, *Liste;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct maillonG
|
||||||
|
{
|
||||||
|
int v;
|
||||||
|
struct maillonG *suiv;
|
||||||
|
Liste l;
|
||||||
|
} MaillonG, *Graphe;
|
||||||
|
|
||||||
|
|
||||||
|
Liste listenouv (void);
|
||||||
|
bool videList (Liste l);
|
||||||
|
Liste insTList (Liste l, int x);
|
||||||
|
Liste insList (Liste l, int x);
|
||||||
|
Liste supTList (Liste l);
|
||||||
|
Liste supList (Liste l, int x);
|
||||||
|
int tList (Liste l);
|
||||||
|
bool rechList (Liste l, int x);
|
||||||
|
int lgList (Liste l);
|
||||||
|
Liste addQList (Liste l, int x);
|
||||||
|
void afficherList (Liste l);
|
Loading…
Reference in new issue