From 42db964e0bc626ddfb48552c0ad4f8affde16422 Mon Sep 17 00:00:00 2001 From: Kyllian Chabanon Date: Thu, 12 Jan 2023 22:28:26 +0100 Subject: [PATCH] =?UTF-8?q?Am=C3=A9liorations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SAE.h | 10 ++++++---- global.c | 6 +++--- menus.c | 19 ++++++++++--------- partie_3.c | 48 +++++++++++++++++++++++++++++++++++++++--------- resultats.txt | 15 ++++++++++++--- structures.c | 20 ++++++++++++++++++++ structures.h | 4 +++- 7 files changed, 93 insertions(+), 29 deletions(-) diff --git a/SAE.h b/SAE.h index f8f7737..9a3fdf7 100755 --- a/SAE.h +++ b/SAE.h @@ -7,11 +7,12 @@ void global(void); /* Menus */ -void menu(VilleIUT *tiut[], int *nbIUT, Etudiant *tetud[], int *nbCandidats, bool *phaseCandidatures, bool *phaseTraitement); +void menu(VilleIUT *tiut[], int *nbIUT, Etudiant *tetud[], int *nbCandidats, bool *phaseCandidatures, bool *phaseTraitement, Etudiant *tetudAdmis[], int *nbEtudAdmis, Etudiant *tetudAttente[], int *nbEtudAttente); void menuAdministrateur(VilleIUT *tiut[], int *nbIUT, Etudiant *tetud[], int *nbCandidats, bool *phaseCandidatures, bool *phaseTraitement); void menuUtilisateur(VilleIUT *tiut[], int *nbIUT, Etudiant *tetud[], int *nbCandidats); void menuCandidat(VilleIUT *tiut[], int *nbIUT, Etudiant *tetud[], int *nbCandidats); -void menuResponsable(Etudiant *tetud[], int *nbCandidats, VilleIUT *tiut[], int *nbIUT); +void menuResponsable(Etudiant *tetud[], int *nbCandidats, VilleIUT *tiut[], int *nbIUT, Etudiant *tetudAdmis[], int *nbEtudAdmis, Etudiant *tetudAttente[], int *nbEtudAttente); + /* Partie 1 */ /* Fichier */ @@ -74,8 +75,9 @@ int inscription(Etudiant *tetud[], int nbCandidats, VilleIUT *tiut[], int nbVill // int menuUtilisateur(ListeUtilisateurs listeUtilisateurs); // void global(void); -int plusGrand(Etudiant *tetudResp[], int nbCandResp); +int plusPetit(Etudiant *tetudResp[], int nbCandResp); void echanger(Etudiant *tetudResp[], int i, int j); void triNote(Etudiant *tetudResp[], int nbCandResp); void deptResp(VilleIUT *tiut[], int nbVilles, char respVille[], char respIUT[]); -int chargementRespDept(Etudiant *tetud[], int nbCand, char respVille[], char respIUT[], Etudiant *tetudResp[]); \ No newline at end of file +int chargementRespDept(Etudiant *tetud[], int nbCand, char respVille[], char respIUT[], Etudiant *tetudResp[]); +void lancerAdmissions(Etudiant *tetudResp[], int nbCandResp, Etudiant *tetudAdmis[], int *nbEtudAdmis, Etudiant *tetudAttente[], int *nbEtudAttente, char ville[], char dept[]); \ No newline at end of file diff --git a/global.c b/global.c index 09f7690..e0f1a93 100755 --- a/global.c +++ b/global.c @@ -2,13 +2,13 @@ void global(void) { - int nbVilles, nbCandidats; + int nbVilles, nbCandidats, nbAdmis = 0, nbAttente = 0; bool phaseCandidatures = true, phaseTraitement = false; VilleIUT *tiut[100]; - Etudiant *tetud[100]; + Etudiant *tetud[100], *admis[100], *attente[100]; nbVilles = chargementVillesIUT(tiut); nbCandidats = chargerCandidats(tetud); - menu(tiut, &nbVilles, tetud, &nbCandidats, &phaseCandidatures, &phaseTraitement); + menu(tiut, &nbVilles, tetud, &nbCandidats, &phaseCandidatures, &phaseTraitement, admis, &nbAdmis, attente, &nbAttente); sauvegardeVillesIUT(tiut, nbVilles); sauvegarderCandidats(tetud, nbCandidats); } diff --git a/menus.c b/menus.c index 798f2d3..b1821f8 100755 --- a/menus.c +++ b/menus.c @@ -1,6 +1,6 @@ #include "SAE.h" -void menu(VilleIUT *tiut[], int *nbIUT, Etudiant *tetud[], int *nbCandidats, bool *phaseCandidatures, bool *phaseTraitement) +void menu(VilleIUT *tiut[], int *nbIUT, Etudiant *tetud[], int *nbCandidats, bool *phaseCandidatures, bool *phaseTraitement, Etudiant *tetudAdmis[], int *nbEtudAdmis, Etudiant *tetudAttente[], int *nbEtudAttente) { int choix; bool c = false; @@ -41,7 +41,7 @@ void menu(VilleIUT *tiut[], int *nbIUT, Etudiant *tetud[], int *nbCandidats, boo menuCandidat(tiut, nbIUT, tetud, nbCandidats); break; case 4: - menuResponsable(tetud, nbCandidats, tiut, nbIUT); + menuResponsable(tetud, nbCandidats, tiut, nbIUT, tetudAdmis, nbEtudAdmis, tetudAttente, nbEtudAttente); break; case 9: c = true; @@ -190,19 +190,20 @@ void menuCandidat(VilleIUT *tiut[], int *nbIUT, Etudiant *tetud[], int *nbCandid } } -void menuResponsable(Etudiant *tetud[], int *nbCandidats, VilleIUT *tiut[], int *nbIUT) +void menuResponsable(Etudiant *tetud[], int *nbCandidats, VilleIUT *tiut[], int *nbIUT, Etudiant *tetudAdmis[], int *nbEtudAdmis, Etudiant *tetudAttente[], int *nbEtudAttente) { int choix; bool c = false; + Etudiant *tetudResp[100]; + int nbCandidatsDept; + char respVille[30], respDept[30]; + deptResp(tiut, *nbIUT, respVille, respDept); + nbCandidatsDept = chargementRespDept(tetud, *nbCandidats, respVille, respDept, tetudResp); + triNote(tetudResp, nbCandidatsDept); //! Ajouter la moyenne et nommer deux liste pour admis et en attente while (c == false) { // system("clear"); - Etudiant *tetudResp[100]; - int nbCandidatsDept; - char respVille[30], respDept[30]; - deptResp(tiut, *nbIUT, respVille, respDept); - nbCandidatsDept = chargementRespDept(tetud, *nbCandidats, respVille, respDept, tetudResp); printf("\n\nMenu des Responsable de Departement : Que voulez-vous faire ?\n"); printf("\t1 - Lancer les admissions\n"); printf("\t2 - Afficher les candidats dans mon département\n"); @@ -224,7 +225,7 @@ void menuResponsable(Etudiant *tetud[], int *nbCandidats, VilleIUT *tiut[], int switch (choix) { case 1: - // lancerAdmission(tetudResp, *nbCandidats); + lancerAdmissions(tetudResp, *nbCandidats, tetudAdmis, nbEtudAdmis, tetudAttente, nbEtudAttente, respVille, respDept); break; case 2: afficherCandidats(tetudResp, nbCandidatsDept); diff --git a/partie_3.c b/partie_3.c index dfe0360..3682bd4 100644 --- a/partie_3.c +++ b/partie_3.c @@ -19,7 +19,6 @@ void deptResp(VilleIUT *tiut[], int nbVilles, char respVille[], char respIUT[]) } //! Rechercher si existe } - } int chargementRespDept(Etudiant *tetud[], int nbCand, char respVille[], char respIUT[], Etudiant *tetudResp[]) @@ -225,11 +224,11 @@ int modifNbPlaces(int nbPlaces) void triNote(Etudiant *tetudResp[], int nbCandResp) { - int pge; + int min; while (nbCandResp > 1) { - pge = plusGrand(tetudResp, nbCandResp); - echanger(tetudResp, pge, nbCandResp - 1); + min = plusPetit(tetudResp, nbCandResp); + echanger(tetudResp, min, nbCandResp - 1); nbCandResp--; } } @@ -241,15 +240,46 @@ void echanger(Etudiant *tetudResp[], int i, int j) tetudResp[j] = aux; } -int plusGrand(Etudiant *tetudResp[], int nbCandResp) +int plusPetit(Etudiant *tetudResp[], int nbCandResp) +{ + int min = 0; + for (int i = 0; i < nbCandResp; i++) + { + if (tetudResp[i]->tabNotes[4] < tetudResp[min]->tabNotes[4]) + { + min = i; + } + } + return min; +} + +void lancerAdmissions(Etudiant *tetudResp[], int nbCandResp, Etudiant *tetudAdmis[], int *nbEtudAdmis, Etudiant *tetudAttente[], int *nbEtudAttente, char ville[], char dept[]) { - int pge = 0; + int placesMax, places = 0, pos; + float moyenneMin; + printf("Entrez la moyenne minimale requise :\n> "); + scanf("%f", &moyenneMin); + printf("Entrez le nombre de places :\n> "); + scanf("%d", &placesMax); for (int i = 0; i < nbCandResp; i++) { - if (tetudResp[i]->tabNotes[moy] > tetudResp[pge]->tabNotes[moy]) + pos = trouverPos(tetudResp[i]->lChoix, ville, dept); + if (tetudResp[i]->tabNotes[4] >= moyenneMin && places < placesMax) + { + setDecisionAdmission(tetudResp[i]->lChoix, pos, 1); + tetudAdmis[*nbEtudAdmis] = tetudResp[i]; + *nbEtudAdmis++; + places++; + } + else if (tetudResp[i]->tabNotes[4] >= moyenneMin) + { + setDecisionAdmission(tetudResp[i]->lChoix, pos, 2); + tetudAdmis[*nbEtudAttente] = tetudResp[i]; + *nbEtudAttente++; + } + else { - pge = i; + setDecisionAdmission(tetudResp[i]->lChoix, pos, -1); } } - return pge; } \ No newline at end of file diff --git a/resultats.txt b/resultats.txt index 7a14784..afc40d1 100755 --- a/resultats.txt +++ b/resultats.txt @@ -1,4 +1,4 @@ -2 +3 1 Dufour Albert @@ -6,7 +6,7 @@ Albert 1 Clermont-Ferrand Informatique -2 +0 0 2 Michel @@ -20,4 +20,13 @@ Informatique Grenoble Informatique 0 -0 \ No newline at end of file +0 +3 +Chabanon +Kyllian +20.00 20.00 20.00 20.00 +1 +Clermont-Ferrand +Informatique +0 +0 diff --git a/structures.c b/structures.c index 11b3100..2c64e99 100755 --- a/structures.c +++ b/structures.c @@ -138,4 +138,24 @@ char *getVilleChoix(ListeChoix lc, int pos) lc = lc->suiv; } return lc->choix.ville; +} + +void setDecisionAdmission(ListeChoix lc, int pos, int val) +{ + for (int i = 0; i < pos; i++) + { + lc = lc->suiv; + } + lc->choix.decisionAdmission = val; +} + +int trouverPos(ListeChoix lc, char ville[], char dept[]) +{ + for (int i = 0; i < longueurChoix(lc); i++) + { + if (strcmp(lc->choix.ville, ville) == 0 && strcmp(lc->choix.departement, dept) == 0) + { + return i; + } + } } \ No newline at end of file diff --git a/structures.h b/structures.h index 68a37a3..0f94029 100644 --- a/structures.h +++ b/structures.h @@ -84,4 +84,6 @@ void afficherChoix(ListeChoix lc); int longueurChoix(ListeChoix lc); void afficherCandidatsChoix(Choix choix); char *getDeptChoix(ListeChoix lc, int pos); -char *getVilleChoix(ListeChoix lc, int pos); \ No newline at end of file +char *getVilleChoix(ListeChoix lc, int pos); +int trouverPos(ListeChoix lc, char ville[], char dept[]); +void setDecisionAdmission(ListeChoix lc, int pos, int val); \ No newline at end of file