|
|
@ -1,4 +1,4 @@
|
|
|
|
#include "Jsae.h"
|
|
|
|
#include "Commun.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************** Fonctions de listes **************************************************************/
|
|
|
|
/*********************************************************** Fonctions de listes **************************************************************/
|
|
|
|
/**********************************************************************************************************************************************/
|
|
|
|
/**********************************************************************************************************************************************/
|
|
|
@ -528,10 +528,11 @@ void miseAJourGlobale(VilleIUT *tiut[], int tLog)
|
|
|
|
clearpage();
|
|
|
|
clearpage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************** Fonctions de login, menus, globale et clearpage **********************************************/
|
|
|
|
// ###########################################################################################
|
|
|
|
/**********************************************************************************************************************************************/
|
|
|
|
// ###########################################################################################
|
|
|
|
/**********************************************************************************************************************************************/
|
|
|
|
// ################################ Commun au 2 parties ######################################
|
|
|
|
|
|
|
|
// ###########################################################################################
|
|
|
|
|
|
|
|
// ###########################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
int login(void) /* Affiche un menu de connexion pour ensuite adapter l'affichage et les fonctionnalités au type d'utilisateur */
|
|
|
|
int login(void) /* Affiche un menu de connexion pour ensuite adapter l'affichage et les fonctionnalités au type d'utilisateur */
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -586,6 +587,7 @@ int login(void) /* Affiche un menu de connexion pour ensuite adapter l'affichage
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax) /* Affiche un menu de choix adaptés pour un administrateur et appelle les fonctions en conséquence */
|
|
|
|
void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax) /* Affiche un menu de choix adaptés pour un administrateur et appelle les fonctions en conséquence */
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int select, pos;
|
|
|
|
int select, pos;
|
|
|
@ -699,7 +701,7 @@ void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax) /* Affiche un menu de choi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax)
|
|
|
|
void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tMaxC)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int select, pos;
|
|
|
|
int select, pos;
|
|
|
|
char ville[31], dept[31];
|
|
|
|
char ville[31], dept[31];
|
|
|
@ -762,7 +764,6 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
afficherPlace(m->d);
|
|
|
|
afficherPlace(m->d);
|
|
|
|
clearpage();
|
|
|
|
clearpage();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(select==4)
|
|
|
|
if(select==4)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -779,11 +780,8 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax)
|
|
|
|
printf("|___________________________________________________|\n");
|
|
|
|
printf("|___________________________________________________|\n");
|
|
|
|
printf("Saisie :");
|
|
|
|
printf("Saisie :");
|
|
|
|
scanf("%d%*c",&select);
|
|
|
|
scanf("%d%*c",&select);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}s
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void clearpage(void) /* Permet de demander à l'utilisateur pour continuer à la suite d'une action et efface le contenu affiché à l'écran */
|
|
|
|
void clearpage(void) /* Permet de demander à l'utilisateur pour continuer à la suite d'une action et efface le contenu affiché à l'écran */
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -847,3 +845,368 @@ void enregistrement(VilleIUT *tiut[],int tLog) /* Permet l'enregistrement du tab
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(flot);
|
|
|
|
fclose(flot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ###########################################################################################
|
|
|
|
|
|
|
|
// ###########################################################################################
|
|
|
|
|
|
|
|
// ################################ Partie II ################################################
|
|
|
|
|
|
|
|
// ###########################################################################################
|
|
|
|
|
|
|
|
// ###########################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************** Fonctiuons de Chargement ********************************************/
|
|
|
|
|
|
|
|
/****************************************** Et de sauvegarde*************************************************/
|
|
|
|
|
|
|
|
/************************************************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Candidat ** chargementCandidats(int *tMax)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *flot;
|
|
|
|
|
|
|
|
Candidat **tCand, *c;
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
flot = fopen("Candidats.don", "r");
|
|
|
|
|
|
|
|
if(flot == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Erreur lors de l'ouverture du fichier candidat\n");
|
|
|
|
|
|
|
|
fclose(flot);
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fscanf(flot, "%d", tMax);
|
|
|
|
|
|
|
|
printf("tMax : %d\n", *tMax);
|
|
|
|
|
|
|
|
tCand = (Candidat **)malloc(sizeof(Candidat *) * (*tMax));
|
|
|
|
|
|
|
|
printf("Allocation du tableau\n");
|
|
|
|
|
|
|
|
if(tCand == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Erreur d'allocation mémoire tableau candidat\n");
|
|
|
|
|
|
|
|
fclose(flot);
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = 0; i < *tMax; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
c = lireCandidat(flot);
|
|
|
|
|
|
|
|
tCand[i] = c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(flot);
|
|
|
|
|
|
|
|
return tCand;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Candidat * lireCandidat(FILE *flot)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Candidat *c;
|
|
|
|
|
|
|
|
Choix choix;
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
c = (Candidat *)malloc(sizeof(Candidat));
|
|
|
|
|
|
|
|
if(c == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Erreur d'allocation mémoire candidat\n");
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fscanf(flot, "%d%*c", &c->numeroC);
|
|
|
|
|
|
|
|
fgets(c->nom, 31, flot);
|
|
|
|
|
|
|
|
c->nom[strlen(c->nom) - 1] = '\0';
|
|
|
|
|
|
|
|
fgets(c->prenom, 31, flot);
|
|
|
|
|
|
|
|
c->prenom[strlen(c->prenom) - 1] = '\0';
|
|
|
|
|
|
|
|
fscanf(flot, "%f%f%f%f%*c", &c->notes[0], &c->notes[1], &c->notes[2], &c->notes[3]);
|
|
|
|
|
|
|
|
fscanf(flot, "%d%*c", &c->nombreChoix);
|
|
|
|
|
|
|
|
c->tChoix = (Choix **)malloc(sizeof(Choix *) * c->nombreChoix);
|
|
|
|
|
|
|
|
while(i < c->nombreChoix)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
c->tChoix[i] = lireChoix(flot);
|
|
|
|
|
|
|
|
i = i + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Choix * lireChoix(FILE *flot)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Choix *c;
|
|
|
|
|
|
|
|
c = (Choix *)malloc(sizeof(Choix));
|
|
|
|
|
|
|
|
if(c == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Erreur d'allocation mémoire choix\n");
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fgets(c->ville, 31, flot);
|
|
|
|
|
|
|
|
c->ville[strlen(c->ville) - 1] = '\0';
|
|
|
|
|
|
|
|
fgets(c->dep, 31, flot);
|
|
|
|
|
|
|
|
c->dep[strlen(c->dep) - 1] = '\0';
|
|
|
|
|
|
|
|
fscanf(flot, "%d%d%*c", &c->decisionResp, &c->decisionCand);
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void sauvegarder(Candidat *tCand[], int tMax)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *flot;
|
|
|
|
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
flot = fopen("CandidatsSauv.don", "w");
|
|
|
|
|
|
|
|
if(flot == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Erreur de l'ouverture du fichier lors de l'enregistrement\n");
|
|
|
|
|
|
|
|
fclose(flot);
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(flot, "%d\n", tMax);
|
|
|
|
|
|
|
|
for(i = 0; i < tMax; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fprintf(flot, "%d\n%s\n%s\n%d\n", tCand[i]->numeroC, tCand[i]->nom, tCand[i]->prenom, tCand[i]->nombreChoix);
|
|
|
|
|
|
|
|
for(j = 0; j < tCand[i]->nombreChoix; j++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fprintf(flot, "%s\n%s\n%d\n%d\n", tCand[i]->tChoix[j]->ville, tCand[i]->tChoix[j]->dep, tCand[i]->tChoix[j]->decisionResp, tCand[i]->tChoix[j]->decisionCand);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(flot);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************** Fonctions d'affichage ********************************************/
|
|
|
|
|
|
|
|
/************************************************************************************************************/
|
|
|
|
|
|
|
|
/************************************************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void afficherChoix(Choix *c)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("|_____________________________________________________________________________|\n");
|
|
|
|
|
|
|
|
printf("| %-32s | %-32s | %1d | %1d |\n", c->ville, c->dep, c->decisionResp, c->decisionCand);
|
|
|
|
|
|
|
|
printf("|-----------------------------------------------------------------------------|\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void afficherCandidat(Candidat *c)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("|------------------------------------------------------------------------------------------------------------|\n");
|
|
|
|
|
|
|
|
printf("| %-4d | %-32s | %-32s | %2.2f | %2.2f | %2.2f | %2.2f |\n", c->numeroC, c->nom, c->prenom, c->notes[0], c->notes[1], c->notes[2], c->notes[3]);
|
|
|
|
|
|
|
|
printf("|------------------------------------------------------------------------------------------------------------|\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void afficherCandChoix(Candidat *tCand[],int tMax)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for(i = 0; i < tMax; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("______________________________________________________________________________________________________________\n");
|
|
|
|
|
|
|
|
printf("| Candidat |\n");
|
|
|
|
|
|
|
|
afficherCandidat(tCand[i]);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
printf("_______________________________________________________________________________\n");
|
|
|
|
|
|
|
|
printf("| Choix |\n");
|
|
|
|
|
|
|
|
for(j = 0; j < tCand[i]->nombreChoix; j++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
afficherChoix(tCand[i]->tChoix[j]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************ Fonctions de réallocation *********************************************/
|
|
|
|
|
|
|
|
/************************************************************************************************************/
|
|
|
|
|
|
|
|
/************************************************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Candidat ** reallocationCand(Candidat *tCand[], int tMax)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Candidat **aux;
|
|
|
|
|
|
|
|
aux = (Candidat **)realloc(tCand, sizeof(Candidat *) * tMax + 1);
|
|
|
|
|
|
|
|
if(aux == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Erreur lors de la réallocation du tableau\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return aux;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Choix ** reallocationChoix(Choix *tChoix[], int nbChoix)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Choix **aux;
|
|
|
|
|
|
|
|
aux = (Choix **)realloc(tChoix, sizeof(Choix *) * nbChoix + 1);
|
|
|
|
|
|
|
|
if(aux == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Erreur lors de la réallocation du tableau\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Réallocation réussie :\n");
|
|
|
|
|
|
|
|
return aux;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************* Fonctions de tri *****************************************************/
|
|
|
|
|
|
|
|
/************************************************************************************************************/
|
|
|
|
|
|
|
|
/************************************************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void triCandidats(Candidat *tCand[], int tMax)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int maxi;
|
|
|
|
|
|
|
|
while(tMax > 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
maxi = plusGrandCand(tCand, tMax);
|
|
|
|
|
|
|
|
echangerCand(tCand, maxi, tMax - 1);
|
|
|
|
|
|
|
|
tMax = tMax - 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int plusGrandCand(Candidat *tCand[], int tMax)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int maxi = 0, i;
|
|
|
|
|
|
|
|
for(i = 1; i < tMax; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(strcmp(tCand[i]->nom, tCand[maxi]->nom) > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
maxi = i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return maxi;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void echangerCand(Candidat *tCand[], int i, int j)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Echange\n");
|
|
|
|
|
|
|
|
Candidat *aux;
|
|
|
|
|
|
|
|
aux = tCand[i];
|
|
|
|
|
|
|
|
tCand[i] = tCand[j];
|
|
|
|
|
|
|
|
tCand[j] = aux;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void triChoix(Choix *tChoix[], int nombreChoix)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int maxi;
|
|
|
|
|
|
|
|
while(nombreChoix > 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
maxi = plusGrandChoix(tChoix, nombreChoix);
|
|
|
|
|
|
|
|
echangerChoix(tChoix, maxi, nombreChoix - 1);
|
|
|
|
|
|
|
|
nombreChoix = nombreChoix - 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int plusGrandChoix(Choix *tChoix[], int nombreChoix)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int maxi = 0, i;
|
|
|
|
|
|
|
|
for(i = 1; i < nombreChoix; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(strcmp(tChoix[i]->ville, tChoix[maxi]->ville) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(strcmp(tChoix[i]->dep, tChoix[maxi]->dep) > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
maxi = i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strcmp(tChoix[i]->ville, tChoix[maxi]->ville) > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
maxi = i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return maxi;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void echangerChoix(Choix *tChoix[], int i, int j)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Echange Choix\n");
|
|
|
|
|
|
|
|
Choix *aux;
|
|
|
|
|
|
|
|
aux = tChoix[i];
|
|
|
|
|
|
|
|
tChoix[i] = tChoix[j];
|
|
|
|
|
|
|
|
tChoix[j] = aux;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************* Fonctions d'insertion/suppresion/maj ***************************************/
|
|
|
|
|
|
|
|
/************************************************************************************************************/
|
|
|
|
|
|
|
|
/************************************************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int insererChoix(Choix *tChoix[], int nombreChoix)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int pos, trouve, i;
|
|
|
|
|
|
|
|
char ville[31], dep[31];
|
|
|
|
|
|
|
|
Choix *c;
|
|
|
|
|
|
|
|
printf("Dans quelle ville se trouve la formation que vous souhaitez ajouter à vos choix ?\nSaisie : ");
|
|
|
|
|
|
|
|
scanf("%s%*c", ville);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
printf("Quelle est le nom de la formation que vous souhaitez ajouter à vos choix ?\nSaisie : ");
|
|
|
|
|
|
|
|
scanf("%s%*c", dep);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
pos = rechercherChoix(tChoix, nombreChoix, ville, dep, &trouve);
|
|
|
|
|
|
|
|
if(trouve == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Erreur, ce choix figure déjà dans votre liste\n");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
c = (Choix *)malloc(sizeof(Choix));
|
|
|
|
|
|
|
|
if(c == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Erreur d'allocation mémoire lors de l'insertion du choix\n");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(c->ville, ville);
|
|
|
|
|
|
|
|
strcpy(c->dep, dep);
|
|
|
|
|
|
|
|
c->decisionResp = 0;
|
|
|
|
|
|
|
|
c->decisionCand = 0;
|
|
|
|
|
|
|
|
tChoix = reallocationChoix(tChoix, nombreChoix);
|
|
|
|
|
|
|
|
for(i = nombreChoix; i > pos; i--)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
tChoix[i] = tChoix[i - 1];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tChoix[pos] = c;
|
|
|
|
|
|
|
|
afficherChoix(tChoix[pos]);
|
|
|
|
|
|
|
|
return nombreChoix + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************** Fonctions de recherche *************************************************/
|
|
|
|
|
|
|
|
/************************************************************************************************************/
|
|
|
|
|
|
|
|
/************************************************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int rechercherChoix(Choix *tChoix[], int nombreChoix, char ville[], char dep[], int *trouve)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int inf = 0, sup = nombreChoix - 1, m;
|
|
|
|
|
|
|
|
while(inf <= sup)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m = (inf + sup) / 2;
|
|
|
|
|
|
|
|
if(strcmp(ville, tChoix[m]->ville) == 0 && strcmp(dep, tChoix[m]->dep) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*trouve = 1;
|
|
|
|
|
|
|
|
return m;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strcmp(ville, tChoix[m]->ville) > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
inf = m + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strcmp(ville, tChoix[m]->ville) < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sup = m - 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strcmp(ville, tChoix[m]->ville) == 0 && strcmp(dep, tChoix[m]->dep) > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
inf = m + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strcmp(ville, tChoix[m]->ville) == 0 && strcmp(dep, tChoix[m]->dep) < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sup = m - 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*trouve = 0;
|
|
|
|
|
|
|
|
return inf;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int rechercherCandidat(Candidat *tCand[], int tMax, char nom[], char prenom[], int *trouve)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int inf = 0, sup = tMax - 1, m;
|
|
|
|
|
|
|
|
while(inf <= sup)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m = (inf + sup) / 2;
|
|
|
|
|
|
|
|
if(strcmp(nom, tCand[m]->nom) == 0 && strcmp(prenom, tCand[m]->prenom) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
*trouve = 1;
|
|
|
|
|
|
|
|
return m;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strcmp(nom, tCand[m]->nom) > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
inf = m + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strcmp(nom, tCand[m]->nom) < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sup = m - 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strcmp(nom, tCand[m]->nom) == 0 && strcmp(prenom, tCand[m]->prenom) > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
inf = m + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(strcmp(nom, tCand[m]->nom) == 0 && strcmp(prenom, tCand[m]->prenom) < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sup = m - 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*trouve = 0;
|
|
|
|
|
|
|
|
return inf;
|
|
|
|
|
|
|
|
}
|