From 9f4995649a17d58733cec6b68d74dd4ffa7f02f9 Mon Sep 17 00:00:00 2001 From: Yann CHAMPEAU Date: Fri, 13 Jan 2023 08:10:39 +0100 Subject: [PATCH] =?UTF-8?q?Tri=20des=20d=C3=A9partements.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/partie1/saeP1.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/partie1/saeP1.c b/src/partie1/saeP1.c index f932f17..84e5ae2 100644 --- a/src/partie1/saeP1.c +++ b/src/partie1/saeP1.c @@ -267,8 +267,16 @@ void creerDep(VilleIUT* tiut[],int tlogi){ } } MaillonDep* m=v->ldept; + printf("\n\nEntrez le nom du département à créer : "); + char nomDep[31] + scanf("%*c%s",nomDep); if(!ck){ - while(m->suivant!=NULL) m=m->suivant; + if(m->suivant==NULL){ + if(strcmp(nomDep,m->departement)>0){ + m=m->suivant; + } + } + while(strcmp(nomDep,m->suivant)>0) m=m->suivant; m->suivant=(MaillonDep*)malloc(sizeof(MaillonDep)); if(m->suivant==NULL){ perror("malloc"); @@ -276,8 +284,7 @@ void creerDep(VilleIUT* tiut[],int tlogi){ } m=m->suivant; } - printf("\n\nEntrez le nom du département à créer : "); - scanf("%*c%s",m->departement); + m->departement=nomDep; printf("\n\nEntrez le nombre de places disponibles dans le département : "); scanf("%d",&m->nbp); printf("\n\nEntrez le nom du responsable de département : \n");