From aa19f5eac57ed5d84ac14330bcd5f32151773ef2 Mon Sep 17 00:00:00 2001 From: Alexis LAURENT Date: Tue, 3 Jan 2023 10:45:01 +0100 Subject: [PATCH] modification des fonction de base (SAEl.c) --- SAEl.c | 138 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 71 insertions(+), 67 deletions(-) diff --git a/SAEl.c b/SAEl.c index 06dda21..730256b 100644 --- a/SAEl.c +++ b/SAEl.c @@ -97,7 +97,6 @@ ListeDept ajouterEnTete(ListeDept l, char *dept, char *nom, int nbP) void affichageListeDept(ListeDept l) // itératif { - printf("DEPARTEMENT NOMBRE DE PLACES CHEF\n"); while (l != NULL) { printf("%s\t%d\t%s\n", l->departement, l->nbPlaces, l->nom); @@ -117,69 +116,72 @@ ListeDept inserer(ListeDept l, char *dept, char *nom, int nbP) return l; } -// ListeDept supprimerEnTête(ListeDept l) -// { -// MaillonDept *aux; -// if (l == NULL) -// { -// printf("suppression interdite\n"); -// exit(1); -// } -// if (l->suiv == NULL) -// return NULL; -// aux = l; -// l = l->suiv; -// free(aux); -// return l; -// } - -// ListeDept supprimer(ListeDept l, int x) -// { -// if (l == NULL) -// return l; -// if (x < l->v) -// return l; // si VRAI x ne peut pas se trouver dans la ListeDept -// if (l->v == x) -// return supprimerEnTête(l); -// l->suiv = supprimer(l->suiv, x); -// return l; -// } +ListeDept supprimerEnTête(ListeDept l) +{ + MaillonDept *aux; + if (l == NULL) + { + printf("suppression interdite\n"); + exit(1); + } + if (l->suiv == NULL) + return NULL; + aux = l; + l = l->suiv; + free(aux); + return l; +} -// void affichageListeDeptR(ListeDept l) -// { -// if (l->suiv == NULL) -// printf("%d\n", l->v); -// printf("%d =>", l->v); -// affichageListeDeptR(l->suiv); -// } +ListeDept supprimer(ListeDept l, char *code) +{ + if (l == NULL) + return l; + if ((strcmp(code,l->departement)) < 0) + return l; + if ((strcmp(code,l->departement)) == 0) + return supprimerEnTête(l); + l->suiv = supprimer(l->suiv, code); + return l; +} -// int tete(ListeDept l) -// { -// if (l == NULL) -// { -// printf("opération interdite\n"); -// exit(1); -// } -// return l->v; -// } +/* +void affichageListeDeptR(ListeDept l) +{ + if (l->suiv == NULL) + printf("%d\n", l->v); + printf("%d =>", l->v); + affichageListeDeptR(l->suiv); +} -// bool vide(ListeDept l) -// { -// if (l == NULL) -// return true; // 1 -// return false; // 0 -// } -// int longueur(ListeDept l) -// { -// int cpt = 0; -// while (l != NULL) -// { -// cpt + 1; -// l = l->suiv; -// } -// return cpt; -// } +int tete(ListeDept l) +{ + if (l == NULL) + { + printf("opération interdite\n"); + exit(1); + } + return l->v; +} +*/ +bool vide(ListeDept l) +{ + if (l == NULL) + return true; // 1 + return false; // 0 +} +/* +int longueur(ListeDept l) +{ + int cpt = 0; + while (l != NULL) + { + cpt + 1; + l = l->suiv; + } + return cpt; +} +*/ bool rechercheDept(ListeDept l, char code[]) { @@ -192,10 +194,12 @@ bool rechercheDept(ListeDept l, char code[]) return recherche(l->suiv, x); } -// ListeDept ajouterEnQueue(ListeDept l, int x) -// { -// if (l == NULL) -// return ajouterEnTête(l, x); -// l->suiv = ajouterEnQueue(l->suiv, x); -// return l; -// } \ No newline at end of file +/* +ListeDept ajouterEnQueue(ListeDept l, int x) +{ + if (l == NULL) + return ajouterEnTête(l, x); + l->suiv = ajouterEnQueue(l->suiv, x); + return l; +} +*/ \ No newline at end of file