From d413a2ca761e0dd1c09630a7c3175c0f7bc70d8c Mon Sep 17 00:00:00 2001 From: "nicolas.blondeau" Date: Thu, 12 Jan 2023 22:27:56 +0100 Subject: [PATCH] =?UTF-8?q?Fonctions=20de=20recherche=20par=20d=C3=A9parte?= =?UTF-8?q?ment,=20par=20ville=20et=20nombre=20de=20places=20fonctionnelle?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utilisateurIut.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/utilisateurIut.c b/utilisateurIut.c index ce0bc24..88db3c1 100644 --- a/utilisateurIut.c +++ b/utilisateurIut.c @@ -52,7 +52,7 @@ int rechercheDept(VilleIUT *tiut[], int n){ char rech[31]; int i, trouve = 0, j = 0; ListeD ld = tiut[i]->ldept; - printf("\nEntrez le nom d'une ville ou d'un IUT : "); + printf("\nEntrez le nom d'une ville : "); scanf("%s%*c", &rech); for(i=0;iville, rech)==0){ @@ -61,7 +61,6 @@ int rechercheDept(VilleIUT *tiut[], int n){ printf("%s\t",ld->departement); printf("Responsable : %s\n",ld->resp); ld = ld->suivant; - return 0; } trouve = 1; } @@ -71,25 +70,22 @@ int rechercheDept(VilleIUT *tiut[], int n){ return 1; } -//FONCTIONNE PAS ENCORE, ERREUR DE SEGMENTATION : int recherchePlaces(VilleIUT *tiut[], int n){ - int err; char rech[31]; - int i, trouve = 0; - printf("OK"); - //err = rechercheDept(tiut, n); ERREUR ICI - printf("OK"); - printf("Quel département ? "); - printf("OK"); - scanf("%s", &rech); - for(i=0;ildept->departement, rech)==0){ - printf("\nNombre de places disponibles : %d\n\n", tiut[i]->ldept->nbP); - trouve = 1; - return 0; + int i, trouve = 0, j = 0; + ListeD ld; + printf("\nEntrez un département : "); + scanf("%s%*c", &rech); + for(i=0;ildept; + if(strcmp(ld->departement, rech)==0){ + printf("\nÀ %s :\n", tiut[i]->ville); + printf("%s\t", ld->departement); + printf("Nombre de places : %d\n",ld->nbP); + ld = ld->suivant; } else if(i==n-1) - printf("\nAucun département trouvé, il n'y pas d'IUT dans votre ville.\n"); + printf("\nAucun département trouvé.\n"); } return 1; }