diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-01-20 13:55:21 +0100 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-01-20 13:55:21 +0100 |
| commit | 42e9569176360b5e1881d317c74ce8522a2af6d1 (patch) | |
| tree | 9df17cba32ac37cf34f486f3fbf335a19f8a14ca /semestre 3/structures des données/td/td8/exo2.c | |
| parent | ecf05510045b2ac78b479ae746a43078e22cee4f (diff) | |
Derniers cours du S3
Diffstat (limited to 'semestre 3/structures des données/td/td8/exo2.c')
| -rw-r--r-- | semestre 3/structures des données/td/td8/exo2.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/semestre 3/structures des données/td/td8/exo2.c b/semestre 3/structures des données/td/td8/exo2.c new file mode 100644 index 0000000..e0cb279 --- /dev/null +++ b/semestre 3/structures des données/td/td8/exo2.c @@ -0,0 +1,34 @@ +#include <stdlib.h> +typedef struct arc { + int v; + struct arc *suiv; +} Arc; + +typedef struct sommet { + int u; + Arc *L_succ; + Arc *L_prec; +} Sommet; + +typedef struct { + int nbsom; + Sommet *t_som; +} Graphe; + +void creeGraphe(Graphe *G, int n){ + G->nbsom = n; + G->t_som = (Sommet*) malloc(sizeof(Graphe)*n); +} + +void ajoutArc(Graphe *G, int i, int j){ + Arc *arcIn = (Arc*) malloc(sizeof(Arc)); + arcIn->v = i; + Arc *arcOut = (Arc*) malloc(sizeof(Arc)); + arcIn->v = j; + Sommet a = G->t_som[i]; + Sommet b = G->t_som[j]; + arcIn->suiv = a.L_succ; + a.L_succ = arcIn; + arcOut->suiv = b.L_prec; + a.L_prec = arcOut; +} |
