From 3cd260105ad7f152d3807a976f913b447fc0ee63 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Fri, 13 Jan 2023 16:03:46 +0100 Subject: [PATCH 1/6] commit --- header/sae.h | 2 +- source/listeDepartements.c | 2 +- source/main.c | 4 +-- source/sae.c | 57 ++++++++++---------------------------- source/test.c | 6 ++-- 5 files changed, 22 insertions(+), 49 deletions(-) diff --git a/header/sae.h b/header/sae.h index 8da1861..9d9cd0d 100644 --- a/header/sae.h +++ b/header/sae.h @@ -133,7 +133,7 @@ void menuAdmin(VilleIut *tiut[], int nbVilles); void afficherCandidat(Candidat candidat); void afficherCandidats(Candidat *candidats, int nbCandidats); -int creerCandid(Candidat tCand[], int nbCandidats); +int creerCandidat(Candidat *tCand[], int nbCandidats); ListeDeptV2 configurationDeptV2( ListeDept ldept ); diff --git a/source/listeDepartements.c b/source/listeDepartements.c index a619668..369411f 100644 --- a/source/listeDepartements.c +++ b/source/listeDepartements.c @@ -99,7 +99,7 @@ ListeDept ajouterDept(ListeDept ldept, char nomDept[], char resp[], int nbP) * * @return La nouvelle liste de départements vide. */ -ListeDept listenouv() +ListeDept listenouv(void) { ListeDept l; diff --git a/source/main.c b/source/main.c index 70adc37..184f5ca 100644 --- a/source/main.c +++ b/source/main.c @@ -8,8 +8,8 @@ int main(void) // #ifdef _WIN32 // color // #endif - - testCharge(); + guillaume(); + //testCharge(); //Globale(); //testJean(); return 0; diff --git a/source/sae.c b/source/sae.c index e20dcf4..15830a3 100644 --- a/source/sae.c +++ b/source/sae.c @@ -732,58 +732,31 @@ void menuAdmin(VilleIut **villeIut, int nbVilles) afficherCandidat(candidats[i]); } } +*/ -int creerCandid(Candidat tCand[], int nbCandidats) +int creerCandidat(Candidat *tCand[], int nbCandidats) { int i=0; - Candidat c; - - printf("Rentrez le numéro du candidat :"); - scanf("%d%*c",&c.numero); - while(inumero = nbCandidats; + printf("Le numero du candidat entrain d'etre cree est : %d\n", c->numero); printf("Nom du candidat (peut contenir des espaces): "); - fgets(c.nom, 50, stdin); - c.nom[strlen(c.nom) - 1] = '\0'; - printf("Prénom du candidat (peut contenir des espaces): "); - fgets(c.prenom, 50, stdin); - c.prenom[strlen(c.prenom) - 1] = '\0'; + fgets(c->nom, 50, stdin); + c->nom[strlen(c->nom) - 1] = '\0'; + printf("Prenom du candidat (peut contenir des espaces): "); + fgets(c->prenom, 50, stdin); + c->prenom[strlen(c->prenom) - 1] = '\0'; i=0; while(i<4) { printf("Rentrez une note : "); - scanf("%f", &c.notes[i]); - printf("%f", c.notes[i]); - i = i + 1; - } - printf("Nombre de choix de candidatures : "); - scanf("%d%*c", &c.nbChoix); - c.nbChoix = (Choix *) malloc (c.nbChoix*sizeof(Choix)); - if(c.nbChoix==NULL) - { - printf("Problème malloc\n"); - exit(1); - } - i=0; - while(inotes[i]); i = i + 1; } - printf("%d %s %s %f %d %s %s %d", c.numero, c.nom, c.prenom, c.notes[1], c.nbChoix, c.choix[0].ville, c.choix[0].departement, c.choix[0].decisionDepartement, c.choix[0].validationCandidat); + c->lchoix = listenouv(); + c = (Candidat *) malloc (sizeof(Candidat)); + tCand[nbCandidats] = c; return nbCandidats + 1; } diff --git a/source/test.c b/source/test.c index 0eb50d3..ece531e 100644 --- a/source/test.c +++ b/source/test.c @@ -40,11 +40,11 @@ void guillaume(void) { - Candidat tCandid[50]; + Candidat *tCandid[50]; int nbCandidats=2; - nbCandidats = creerCandid(tCandid, nbCandidats); - printf("\n%d", nbCandidats); + nbCandidats = creerCandidat(tCandid, nbCandidats); + printf("\n%d\n", nbCandidats); } From 1e44c16cc13bd869c6985ecb90975b4d61d170ea Mon Sep 17 00:00:00 2001 From: Guillaume Date: Fri, 13 Jan 2023 16:06:21 +0100 Subject: [PATCH 2/6] commit --- source/sae.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/sae.c b/source/sae.c index 15830a3..b16774f 100644 --- a/source/sae.c +++ b/source/sae.c @@ -754,7 +754,7 @@ int creerCandidat(Candidat *tCand[], int nbCandidats) scanf("%f", &c->notes[i]); i = i + 1; } - c->lchoix = listenouv(); + c->lchoix = listenouvC(); c = (Candidat *) malloc (sizeof(Candidat)); tCand[nbCandidats] = c; return nbCandidats + 1; From 136377ff7fc55cbd0ecf0c36f03a0d410c60550a Mon Sep 17 00:00:00 2001 From: Guillaume Date: Fri, 13 Jan 2023 16:17:57 +0100 Subject: [PATCH 3/6] fonction creerCandidat finie normalment youpi --- source/sae.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source/sae.c b/source/sae.c index b16774f..5911849 100644 --- a/source/sae.c +++ b/source/sae.c @@ -739,6 +739,12 @@ int creerCandidat(Candidat *tCand[], int nbCandidats) int i=0; Candidat *c; + c = (Candidat *) malloc (sizeof(Candidat)); + if(c==NULL) + { + printf("Probleme malloc\n"); + exit(1); + } c->numero = nbCandidats; printf("Le numero du candidat entrain d'etre cree est : %d\n", c->numero); printf("Nom du candidat (peut contenir des espaces): "); @@ -750,12 +756,16 @@ int creerCandidat(Candidat *tCand[], int nbCandidats) i=0; while(i<4) { - printf("Rentrez une note : "); + printf("Rentrez la note numero %d : ", i+1); scanf("%f", &c->notes[i]); + while(c->notes[i] < 0 || c->notes[i] > 20) + { + printf("Erreur, la note doit etre comprise entre 0 et 20.\nRessaisir la note numero %d : ", i+1); + scanf("%f", &c->notes[i]); + } i = i + 1; } c->lchoix = listenouvC(); - c = (Candidat *) malloc (sizeof(Candidat)); tCand[nbCandidats] = c; return nbCandidats + 1; } From 5537943d704d15ec2bbdf078a5d75b2b4699a739 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Fri, 13 Jan 2023 16:32:15 +0100 Subject: [PATCH 4/6] fonction creerCandidat + affichage qui marche youpi --- header/sae.h | 8 +------- source/sae.c | 4 +++- source/test.c | 3 ++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/header/sae.h b/header/sae.h index 620b2c1..55fc3e6 100644 --- a/header/sae.h +++ b/header/sae.h @@ -131,15 +131,9 @@ void afficheNbPlacesDep(VilleIut *tiut[], int nbVilles, char nomDept[]); int existeVille( VilleIut *tiut[], char ville[], int nbvilles ); void menuAdmin(VilleIut *tiut[], int nbVilles); -<<<<<<< HEAD -void afficherCandidat(Candidat candidat); -void afficherCandidats(Candidat *candidats, int nbCandidats); -int creerCandidat(Candidat *tCand[], int nbCandidats); -======= void afficherUnCandidat(Candidat candidat); void afficherCandidats(Candidat **candidats, int nbCandidats); -int creerCandid(Candidat tCand[], int nbCandidats); ->>>>>>> bcdeb24491974b30c7e1ad6913f0e3fa2c3be9c3 +int creerCandidat(Candidat *tCand[], int nbCandidats); ListeDeptV2 configurationDeptV2( ListeDept ldept ); diff --git a/source/sae.c b/source/sae.c index af34e03..00e22b6 100644 --- a/source/sae.c +++ b/source/sae.c @@ -732,8 +732,10 @@ void menuAdmin(VilleIut **villeIut, int nbVilles) void afficherCandidats(Candidat **candidats, int nbCandidats) { for (int i = 0; i < nbCandidats; i++) + { printf("\nCandidat numero %8d | Nom : %10s | Prenom : %10s \n", candidats[i] -> numero, candidats[i] -> nom, candidats[i] -> prenom); + } } @@ -748,7 +750,7 @@ int creerCandidat(Candidat *tCand[], int nbCandidats) printf("Probleme malloc\n"); exit(1); } - c->numero = nbCandidats; + c->numero = nbCandidats+1; printf("Le numero du candidat entrain d'etre cree est : %d\n", c->numero); printf("Nom du candidat (peut contenir des espaces): "); fgets(c->nom, 50, stdin); diff --git a/source/test.c b/source/test.c index ece531e..155aeb9 100644 --- a/source/test.c +++ b/source/test.c @@ -41,10 +41,11 @@ void guillaume(void) { Candidat *tCandid[50]; - int nbCandidats=2; + int nbCandidats=0; nbCandidats = creerCandidat(tCandid, nbCandidats); printf("\n%d\n", nbCandidats); + afficherCandidats(tCandid, nbCandidats); } From d233c5c0dff333cf0d07c43cbdb0fb081a876a45 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Fri, 13 Jan 2023 16:33:03 +0100 Subject: [PATCH 5/6] fonction creerCandidat + affichage qui marche youpi --- source/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/main.c b/source/main.c index 184f5ca..08240ef 100644 --- a/source/main.c +++ b/source/main.c @@ -8,7 +8,7 @@ int main(void) // #ifdef _WIN32 // color // #endif - guillaume(); + //guillaume(); //testCharge(); //Globale(); //testJean(); From 73f9f3b4b48684e6efe3e9b90cab08641a75bb25 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Fri, 13 Jan 2023 16:43:18 +0100 Subject: [PATCH 6/6] =?UTF-8?q?commentaires=20sur=20la=20fonction=20cr?= =?UTF-8?q?=C3=A9er=20candidat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/sae.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/sae.c b/source/sae.c index 00e22b6..0beb9a8 100644 --- a/source/sae.c +++ b/source/sae.c @@ -738,7 +738,14 @@ void afficherCandidats(Candidat **candidats, int nbCandidats) } } - +/** + * @brief Permet de créer un candidat + * + * @param tCand Tableau de pointeur sur une structure de candidat + * @param nbCandidats nombre de candidats créés + * + * @return Retourne le nombre de candidats + */ int creerCandidat(Candidat *tCand[], int nbCandidats) { int i=0; @@ -776,6 +783,8 @@ int creerCandidat(Candidat *tCand[], int nbCandidats) } + + /* ================================================ Partie 3