diff --git a/SAE.h b/SAE.h index a24fe48..9dee363 100755 --- a/SAE.h +++ b/SAE.h @@ -7,12 +7,13 @@ 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 menuAffichage(Etudiant *tetud[], int nbCandidats, VilleIUT *tiut[], int *nbIUT); +void menuAffichage(Etudiant *tetud[], int nbCandidats, VilleIUT *tiut[], int *nbIUT, Etudiant *tetudAdmis[], int *nbEtudAdmis, Etudiant *tetudAttente[], int *nbEtudAttente); + /* Partie 1 */ /* Fichier */ @@ -75,8 +76,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 086005e..400e39e 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,10 +190,16 @@ 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) @@ -226,7 +232,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: menuAffichage(tetud, nbCandidats, tiut, nbIUT); diff --git a/partie_3.c b/partie_3.c index cbdccb8..3682bd4 100644 --- a/partie_3.c +++ b/partie_3.c @@ -224,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--; } } @@ -240,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 pge = 0; + int min = 0; for (int i = 0; i < nbCandResp; i++) { - if (tetudResp[i]->tabNotes[moy] > tetudResp[pge]->tabNotes[moy]) + if (tetudResp[i]->tabNotes[4] < tetudResp[min]->tabNotes[4]) { - pge = i; + min = i; + } + } + return min; +} + +void lancerAdmissions(Etudiant *tetudResp[], int nbCandResp, Etudiant *tetudAdmis[], int *nbEtudAdmis, Etudiant *tetudAttente[], int *nbEtudAttente, char ville[], char dept[]) +{ + 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++) + { + 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 + { + 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 6ea62c3..5ab6262 100644 --- a/structures.h +++ b/structures.h @@ -83,4 +83,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