Ajout du tri par moyenne

master
Johnny RATTON 2 years ago
parent 399fcc4caf
commit 550a1081a9

@ -860,6 +860,32 @@ void echangerChoix(Choix *tChoix[], int i, int j) /* Fonction permettant d'écha
}
/* Tri échanges pour trier par rapport aux moyennes */
void triTemp(Candidat *tCand[], int nbCl) /* Fonction permettant de trier un tableau de candidats en effectuant un tri par échange */
{
int maxi;
while(nbCl > 1)
{
plusGrandCandTemp(tCand, nbCl); /* Appel de la fonction plusGrand pour déterminer le plus grand élément du tableau */
echangerCand(tCand, maxi, nbCl - 1); /* Appel de la fonction échange pour placer le plus grnad élément du tableau en dernière position */
nbCl = nbCl - 1;
}
}
int plusGrandCandTemp(Candidat *tCand[], int nbCl) /* Fonction permettant de trouver le plus grand élément du tableau candidat en le parcourant et en*/
{ /* comparant ses éléments. Elle renvoie ensuite l'indice du plus grand élément */
int maxi = 0, i;
for(i = 1; i < nbCl; i++)
{
if(tCand[i]->moyenne > tCand[maxi]->moyenne)
{
maxi = i;
}
}
return maxi;
}
/******************************* Fonctions d'insertion/suppresion/maj ***************************************/
/************************************************************************************************************/
/************************************************************************************************************/
@ -1124,13 +1150,15 @@ Candidat** remplirCandCl(Candidat *tCand[], Candidat *tempC[], int tMax, int nbC
{
for(j = 0; j < tCand[i]->nombreChoix; j++)
{
if(strcmp(tCand[i]->tChoix[j]->ville, "Clermont-Ferrand") == 0 && strcmp(tCand[i]->tChoix[j].dep, "Informatique" == 0)
if(strcmp(tCand[i]->tChoix[j]->ville, "Clermont-Ferrand") == 0 && strcmp(tCand[i]->tChoix[j].dep, "Informatique") == 0)
{
tempC[k] = tCand[i];
k = k + 1;
}
}
}
triTemp(tempC, nbCl);
return tempC;
}
/*********************************** Fonctions de recherche *************************************************/

@ -3,6 +3,10 @@
#include <string.h>
#include <stdbool.h>
/*####################################################################################################################################################*/
/*################################################################# Partie I #########################################################################*/
/*####################################################################################################################################################*/
typedef struct
{
char dept[31];
@ -23,6 +27,59 @@ typedef struct
ListeDept lDept;
} VilleIUT;
/* Fonctions de Chargement */
int chargement(VilleIUT *tiut[],int tMax);
Departement lireDep(FILE *flot);
void enregistrement(VilleIUT *tiut[], int tLog);
/* Fonctions d'affichage */
void afficherPlace(Departement d);
void afficherDep(Departement d);
void afficherVille(VilleIUT v);
void afficherTIUT(VilleIUT *tiut[], int tLog);
void afficherVilleDep(VilleIUT v);
void afficheDeptDesIUT(VilleIUT *tiut[], int tLog);
/* Fonctions de Listes */
ListeDept listeDeptNouv(void);
ListeDept insererEntete(ListeDept lDept,Departement d);
ListeDept insererDept(ListeDept lDept, Departement d);
ListeDept supprimerEntete(ListeDept lDept);
ListeDept supprimerDept(ListeDept lDept, char *dep);
bool vide(ListeDept lDept);
int longueur(ListeDept lDept);
/* Fonctions de département */
void creerDept(VilleIUT *tiut[],int tLog);
void retirerDept(VilleIUT *tiut[], int tLog);
/* Fonctions de gestion du tableau */
int insererVille(VilleIUT *tiut[], char nomV[], int *tLog, int tMax, int pos);
int supprimerVille(VilleIUT *tiut[], char nomV[], int *tLog, int pos);
/* Fonctions de recherche */
ListeDept rechercherDept(ListeDept lDept, char dept[], int *trouve);
int rechercheIUT(VilleIUT *tiut[], int tLog, char ville[], int *trouve);
/* Fonctions de mise à jour */
void miseAJourGlobale(VilleIUT *tiut[], int tLog);
void miseAJourNomDept(Departement *d,ListeDept l);
void miseAJourResp(Departement *d);
void miseAJourPlaces(Departement *d);
/*####################################################################################################################################################*/
/*################################################################# Partie II ########################################################################*/
/*####################################################################################################################################################*/
typedef struct
{
char ville[31];
@ -84,6 +141,8 @@ void echangerCand(Candidat *tCand[], int i, int j);
void triChoix(Choix *tChoix[], int nombreChoix);
int plusGrandChoix(Choix *tChoix[], int nombreChoix);
void echangerChoix(Choix *tChoix[], int i, int j);
void triTemp(Candidat *tCand[], int nbCl);
int plusGrandCandTemp(Candidat *tCand[], int nbCl);
/* Fonctions de recherche */
@ -96,7 +155,8 @@ Choix ** insererChoix(Choix *tChoix[], int *nombreChoix);
Choix ** supprimerChoix(Choix *tChoix[], int *nombreChoix);
int miseAJourChoixCand(Choix *tChoix[], int nombreChoix);
/* void miseAJourChoixResp(Choix *tChoix[], int pos); */
Candidat ** creerCandidat(Candidat *tCand[], int *tMax);
Candidat ** creerCandidat(Candidat *tCand[], int *tMax, int *pos);
Candidat** remplirCandCl(Candidat *tCand[], Candidat *tempC[], int tMax, int nbCl);
/* Fonctions de file d'attente */
@ -119,6 +179,8 @@ bool videListe(ListeCand lCand);
ListeCand rechercherCandListe(ListeCand lCand, int numeroC, int *trouve);
/* Fonctions globale, menus*/
void globale2(void);
void menuCandidat2(Candidat *tCand[], int tMax);
void lancerPhaseCandidature(int *phaseCandidature);
void globale(void);
void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tMaxC,int posC,int phaseCandidature);
void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax,int *phaseCandidature);
void clearpage(void);
Loading…
Cancel
Save