From 42e9569176360b5e1881d317c74ce8522a2af6d1 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 20 Jan 2026 13:55:21 +0100 Subject: Derniers cours du S3 --- .../structures des donn\303\251es/td/td8/exo2.c" | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "semestre 3/structures des donn\303\251es/td/td8/exo2.c" (limited to 'semestre 3/structures des données/td/td8/exo2.c') diff --git "a/semestre 3/structures des donn\303\251es/td/td8/exo2.c" "b/semestre 3/structures des donn\303\251es/td/td8/exo2.c" new file mode 100644 index 0000000..e0cb279 --- /dev/null +++ "b/semestre 3/structures des donn\303\251es/td/td8/exo2.c" @@ -0,0 +1,34 @@ +#include +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; +} -- cgit v1.2.3