From cc6289dbae123945f5dacccef9312d46017cd11c Mon Sep 17 00:00:00 2001 From: Siwa12100 Date: Fri, 13 Jan 2023 13:59:56 +0100 Subject: [PATCH 1/2] ajoute de existeVille ( jean ) --- header/sae.h | 1 + source/sae.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/header/sae.h b/header/sae.h index de7b7c7..5a6c174 100644 --- a/header/sae.h +++ b/header/sae.h @@ -122,6 +122,7 @@ int modifieRespDept(VilleIut *tVilleIut[], int nbVilles, char ville[], char nomD void afficheIUTDept(VilleIut* *villeIut, int nbVilles, char *nomDept); void afficheVillesIUT(VilleIut **villeIut, int nbVilles); void afficheNbPlacesDep(VilleIut *tVilleIut[], int nbVilles, char nomDept[]); +int existeVille( VilleIut * tIut[], char ville[], int nbvilles ); void menuAdmin(VilleIut **villeIut, int nbVilles); void afficherCandidat(Candidat candidat); diff --git a/source/sae.c b/source/sae.c index 44fe570..b1d85bd 100644 --- a/source/sae.c +++ b/source/sae.c @@ -514,7 +514,18 @@ void afficheNbPlacesDep(VilleIut *tVilleIut[], int nbVilles, char nomDept[]) } +int existeVille( VilleIut * tIut[], char ville[], int nbvilles ) +{ + int i = 0; + // Recherche de la ville + for ( i = 0; i < nbvilles, i ++ ) + { + if ( strcmp( tIut[i] -> nom, ville ) == 0 ) return i; + } + + return -1; +} /** * Affiche et gère le menu administrateur. @@ -581,10 +592,6 @@ void menuAdmin(VilleIut **villeIut, int nbVilles) } - - - - /* ================================================ Partie 2 From 303ec81f87a7594f2aeaa1b1e9bf497d152692bc Mon Sep 17 00:00:00 2001 From: Siwa12100 Date: Fri, 13 Jan 2023 14:06:05 +0100 Subject: [PATCH 2/2] ajoute de existeVille ( jean ) --- source/sae.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/sae.c b/source/sae.c index 62c01a6..5bfc45c 100644 --- a/source/sae.c +++ b/source/sae.c @@ -596,6 +596,17 @@ void afficheNbPlacesDep(VilleIut *tVilleIut[], int nbVilles, char nomDept[]) } } +int existeVille( VilleIut * tIut[], char ville[], int nbvilles ) +{ + int i = 0; + + //recherche de la ville + for( e = 0; i < nbvilles; i ++ ) + { + if ( strcmp( tIut[i] -> nom, ville ) == 0 ) return i; // ville trouvée... + } + return -1; +} /** * Affiche et gère le menu administrateur.