You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

255 lines
6.3 KiB

#include "SAE.h"
void deptResp(VilleIUT *tiut[], int nbVilles, char respVille[], char respIUT[])
{
char nom[30];
printf("Entrez votre nom et votre prénom :\n> ");
fgets(nom, 30, stdin);
nom[strlen(nom) - 1] = '\0';
for (int i = 0; i < nbVilles; i++)
{
for (int n = 0; n < longueur(tiut[i]->ldept); n++)
{
if (strcmp(getResp(tiut[i]->ldept, n), nom) == 0)
{
strcpy(respVille, tiut[i]->ville);
strcpy(respIUT, getDept(tiut[i]->ldept, n));
return;
}
}
//! Rechercher si existe
}
}
int chargementRespDept(Etudiant *tetud[], int nbCand, char respVille[], char respIUT[], Etudiant *tetudResp[])
{
int nb = 0;
for (int i = 0; i < nbCand; i++)
{
for (int n = 0; n < tetud[i]->nbChoix; n++)
{
if (strcmp(getDeptChoix(tetud[i]->lChoix, n), respIUT) == 0 && strcmp(getVilleChoix(tetud[i]->lChoix, n), respVille) == 0)
{
tetudResp[nb] = tetud[i];
nb++;
}
}
}
return nb;
}
void afficherCandidatsAdmis(Etudiant *tetud[], int nbCandidats)
{
Etudiant mEtudiant;
for (int i = 0; i < nbCandidats; i++)
{
mEtudiant = *tetud[i];
if (tetud[i]->lChoix->choix.decisionAdmission == 1)
{
afficherEtudiant(*tetud[i]);
}
}
} // TODO : Mettre un message d'erreur si aucun
void afficherCandidatsRefuses(Etudiant *tetud[], int nbCandidats)
{
Etudiant mEtudiant;
for (int i = 0; i < nbCandidats; i++)
{
mEtudiant = *tetud[i];
if (mEtudiant.lChoix->choix.decisionAdmission == -1)
{
afficherEtudiant(mEtudiant);
}
}
}
void afficherCandidatsAttente(Etudiant *tetud[], int nbCandidats)
{
Etudiant mEtudiant;
for (int i = 0; i < nbCandidats; i++)
{
mEtudiant = *tetud[i];
if (tetud[i]->lChoix->choix.decisionAdmission == 2)
{
afficherEtudiant(*tetud[i]);
}
}
}
Etudiant moyenneCandidat(Etudiant mEtudiant)
{
float moyenne = 0;
for (int i = 0; i < 4; i++)
{
moyenne += mEtudiant.tabNotes[i];
}
moyenne /= 4;
mEtudiant.tabNotes[moy] = moyenne;
return mEtudiant;
}
Etudiant *moyenneCandidats(Etudiant *tetud[], int nbCandidats)
{
for (int i = 0; i < nbCandidats; i++)
{
*tetud[i] = moyenneCandidat(*tetud[i]);
}
return *tetud;
}
Etudiant modifStatueCandidat(Etudiant *tetud[], int nbCandidats, float noteMin[], float noteExel[])
{
for (int i = 0; i < nbCandidats; i++)
{
if (tetud[i]->tabNotes[maths] >= noteMin[maths] && tetud[i]->tabNotes[francais] >= noteMin[francais] && tetud[i]->tabNotes[anglais] >= noteMin[anglais] && tetud[i]->tabNotes[spe] >= noteMin[spe] && tetud[i]->tabNotes[moy] >= noteMin[moy])
{
tetud[i]->lChoix->choix.decisionAdmission = 2;
}
else if (tetud[i]->tabNotes[maths] >= noteExel[maths] && tetud[i]->tabNotes[francais] >= noteExel[francais] && tetud[i]->tabNotes[anglais] >= noteExel[anglais] && tetud[i]->tabNotes[spe] >= noteExel[spe] && tetud[i]->tabNotes[moy] >= noteExel[moy])
{
tetud[i]->lChoix->choix.decisionAdmission = 1;
}
else
{
tetud[i]->lChoix->choix.decisionAdmission = -1;
}
}
return **tetud;
}
int statueCandidat(Etudiant *tetud[], int nbCandidats)
{
for (int i = 0; i < nbCandidats; i++)
{
if (tetud[i]->lChoix->choix.decisionAdmission == 1)
{
return 1;
}
else if (tetud[i]->lChoix->choix.decisionAdmission == -1)
{
return -1;
}
else
{
return 2;
}
}
}
int nbCandidatsAdmis(Etudiant *tetud[], int nbCandidats)
{
int nbAdmis = 0;
for (int i = 0; i < nbCandidats; i++)
{
if (tetud[i]->lChoix->choix.decisionAdmission == 1)
{
nbAdmis++;
}
}
return nbAdmis;
}
int nbCandidatsRefuses(Etudiant *tetud[], int nbCandidats)
{
int nbRefuses = 0;
for (int i = 0; i < nbCandidats; i++)
{
if (tetud[i]->lChoix->choix.decisionAdmission == -1)
{
nbRefuses++;
}
}
return nbRefuses;
}
int nbCandidatsAttente(Etudiant *tetud[], int nbCandidats)
{
int nbAttente = 0;
for (int i = 0; i < nbCandidats; i++)
{
if (tetud[i]->lChoix->choix.decisionAdmission == 2)
{
nbAttente++;
}
}
return nbAttente;
}
float modifNoteMin(float noteMin[])
{
for (int i = 0; i < 5; i++)
{
printf("Entrez la note minimale pour la matiere %s (0/20, -1 pour sortir) : ", i + 1); // afficher le nom de la matiere du enum
scanf("%f", &noteMin[i]);
while (noteMin[i] < 0 || noteMin[i] > 20)
{
scanf("%f", &noteMin[i]);
if (noteMin[i] == -1)
{
break;
}
printf("La note doit être comprise entre 0 et 20 !\n");
}
}
return *noteMin;
}
float modifNoteExel(float noteExel[])
{
for (int i = 0; i < 5; i++)
{
printf("Entrez la note minimale pour la matiere %s (0/20, -1 pour sortir) : ", i + 1); // afficher le nom de la matiere du enum
scanf("%f", &noteExel[i]);
while (noteExel[i] < 0 || noteExel[i] > 20)
{
scanf("%f", &noteExel[i]);
if (noteExel[i] == -1)
{
break;
}
printf("La note doit être comprise entre 0 et 20 !\n");
}
}
return *noteExel;
}
int modifNbPlaces(int nbPlaces)
{
printf("Entrez le nombre de places disponibles : ");
scanf("%d", &nbPlaces);
return nbPlaces;
}
void triNote(Etudiant *tetudResp[], int nbCandResp)
{
int pge;
while (nbCandResp > 1)
{
pge = plusGrand(tetudResp, nbCandResp);
echanger(tetudResp, pge, nbCandResp - 1);
nbCandResp--;
}
}
void echanger(Etudiant *tetudResp[], int i, int j)
{
Etudiant *aux;
aux = tetudResp[i];
tetudResp[i] = tetudResp[j];
tetudResp[j] = aux;
}
int plusGrand(Etudiant *tetudResp[], int nbCandResp)
{
int pge = 0;
for (int i = 0; i < nbCandResp; i++)
{
if (tetudResp[i]->tabNotes[moy] > tetudResp[pge]->tabNotes[moy])
{
pge = i;
}
}
return pge;
}