|
|
|
@ -61,6 +61,8 @@ void ajouterCandidature(Candidat* candidat, Candidature* candidature) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void menuCandidat_candidater(VilleIUT** tiut, int nbVilles, Candidat* candidat) {
|
|
|
|
|
int found = 0;
|
|
|
|
|
ListeDept liste;
|
|
|
|
|
Candidature* candid = creerCandidature();
|
|
|
|
|
|
|
|
|
|
char searchIUT[LEN_MAX], searchDept[LEN_MAX];
|
|
|
|
@ -80,8 +82,7 @@ void menuCandidat_candidater(VilleIUT** tiut, int nbVilles, Candidat* candidat)
|
|
|
|
|
printf("Entrez le département dans lequel vous souhaitez candidater : ");
|
|
|
|
|
scanf("%*c%[^\n]", searchDept);
|
|
|
|
|
|
|
|
|
|
int found = 0;
|
|
|
|
|
ListeDept liste = tiut[i]->ldept;
|
|
|
|
|
liste = tiut[i]->ldept;
|
|
|
|
|
|
|
|
|
|
if(strcmp(liste->departement, searchDept) == 0)
|
|
|
|
|
found=1;
|
|
|
|
@ -111,9 +112,9 @@ void menuCandidat_candidater(VilleIUT** tiut, int nbVilles, Candidat* candidat)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int checkCandidature(Candidat* candidat, Candidature candid) {
|
|
|
|
|
int nbCandidatures = candidat->nbCandidatures;
|
|
|
|
|
int i, nbCandidatures = candidat->nbCandidatures;
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<nbCandidatures; i++)
|
|
|
|
|
for(i=0; i<nbCandidatures; i++)
|
|
|
|
|
if(strcmp(candidat->listeCandidatures[i]->ville, candid.ville) == 0)
|
|
|
|
|
if(strcmp(candidat->listeCandidatures[i]->departement, candid.departement) == 0)
|
|
|
|
|
return -1;
|
|
|
|
@ -122,6 +123,7 @@ int checkCandidature(Candidat* candidat, Candidature candid) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void afficherListeCandidats(ListeCandidats liste, int nbCandidats) {
|
|
|
|
|
Candidat* candidat;
|
|
|
|
|
ListeCandidats liste2 = (ListeCandidats) malloc(nbCandidats*sizeof(Candidat*));
|
|
|
|
|
|
|
|
|
|
if(liste2 == NULL) {
|
|
|
|
@ -136,7 +138,7 @@ void afficherListeCandidats(ListeCandidats liste, int nbCandidats) {
|
|
|
|
|
qsort(liste2, nbCandidats, sizeof(Candidat*), compareCandidats);
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<nbCandidats; i++) {
|
|
|
|
|
Candidat* candidat = liste2[i];
|
|
|
|
|
candidat = liste2[i];
|
|
|
|
|
|
|
|
|
|
afficherCandidat(candidat);
|
|
|
|
|
}
|
|
|
|
@ -210,8 +212,8 @@ void afficherCandidatures(ListeCandidatures candidatures, int nbCandidatures) {
|
|
|
|
|
afficherCandidatures(candidatures, nbCandidatures-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
void afficherCandidatures_(Candidat* candidat) {
|
|
|
|
|
/* Fonction originale sans récursivité
|
|
|
|
|
void afficherCandidatures_sansRecursif(Candidat* candidat) {
|
|
|
|
|
int nbCandidatures = candidat->nbCandidatures;
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<nbCandidatures; i++) {
|
|
|
|
@ -259,6 +261,12 @@ void afficherCandidatures_(Candidat* candidat) {
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
ListeCandidats readCandidats(int* nbCandidats) {
|
|
|
|
|
int i, j;
|
|
|
|
|
Candidat* candidat;
|
|
|
|
|
Candidature* candidature;
|
|
|
|
|
ListeCandidats liste;
|
|
|
|
|
ListeCandidatures listeCandidatures;
|
|
|
|
|
|
|
|
|
|
FILE *fe = fopen("donnees/candidats.don", "r");
|
|
|
|
|
|
|
|
|
|
if(fe == NULL) {
|
|
|
|
@ -268,22 +276,22 @@ ListeCandidats readCandidats(int* nbCandidats) {
|
|
|
|
|
|
|
|
|
|
fscanf(fe, "%d", nbCandidats);
|
|
|
|
|
|
|
|
|
|
ListeCandidats liste = (ListeCandidats) malloc(*nbCandidats*sizeof(Candidat*));
|
|
|
|
|
liste = (ListeCandidats) malloc(*nbCandidats*sizeof(Candidat*));
|
|
|
|
|
|
|
|
|
|
if(liste == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
|
exit(errno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<*nbCandidats; i++) {
|
|
|
|
|
Candidat* candidat = creerCandidat();
|
|
|
|
|
for(i=0; i<*nbCandidats; i++) {
|
|
|
|
|
candidat = creerCandidat();
|
|
|
|
|
fscanf(fe, "%d\n%[^\n]\n%[^\n]\n%f\n%f\n%f\n%f\n%d",
|
|
|
|
|
&candidat->id, candidat->nom, candidat->prenom,
|
|
|
|
|
&candidat->moyenneMath, &candidat->moyenneFrancais,
|
|
|
|
|
&candidat->moyenneAnglais, &candidat->moyenneSpecialite,
|
|
|
|
|
&candidat->nbCandidatures);
|
|
|
|
|
|
|
|
|
|
ListeCandidatures listeCandidatures = (ListeCandidatures) malloc(candidat->nbCandidatures*sizeof(Candidature*));
|
|
|
|
|
listeCandidatures = (ListeCandidatures) malloc(candidat->nbCandidatures*sizeof(Candidature*));
|
|
|
|
|
|
|
|
|
|
if(listeCandidatures == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
@ -292,8 +300,8 @@ ListeCandidats readCandidats(int* nbCandidats) {
|
|
|
|
|
|
|
|
|
|
candidat->listeCandidatures = listeCandidatures;
|
|
|
|
|
|
|
|
|
|
for(int j=0; j<candidat->nbCandidatures; j++) {
|
|
|
|
|
Candidature* candidature = (Candidature*) malloc(sizeof(Candidature));
|
|
|
|
|
for(j=0; j<candidat->nbCandidatures; j++) {
|
|
|
|
|
candidature = (Candidature*) malloc(sizeof(Candidature));
|
|
|
|
|
|
|
|
|
|
if(candidature == NULL) {
|
|
|
|
|
perror("malloc");
|
|
|
|
@ -316,11 +324,10 @@ int compareCandidats(const void* p1, const void* p2) {
|
|
|
|
|
Candidat* c1 = *(ListeCandidats) p1;
|
|
|
|
|
Candidat* c2 = *(ListeCandidats) p2;
|
|
|
|
|
|
|
|
|
|
char nomComplet1[60];
|
|
|
|
|
char nomComplet1[60], nomComplet2[60];
|
|
|
|
|
strcpy(nomComplet1, c1->nom);
|
|
|
|
|
strcat(nomComplet1, c1->prenom);
|
|
|
|
|
|
|
|
|
|
char nomComplet2[60];
|
|
|
|
|
strcpy(nomComplet2, c2->nom);
|
|
|
|
|
strcat(nomComplet2, c2->prenom);
|
|
|
|
|
|
|
|
|
@ -328,6 +335,11 @@ int compareCandidats(const void* p1, const void* p2) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int saveCandidats(ListeCandidats liste, int nbCandidats) {
|
|
|
|
|
int i, j;
|
|
|
|
|
Candidat* candidat;
|
|
|
|
|
Candidature* candidature;
|
|
|
|
|
ListeCandidatures listeCandidatures;
|
|
|
|
|
|
|
|
|
|
FILE *fe = fopen("donnees/candidats.don", "w");
|
|
|
|
|
|
|
|
|
|
if(fe == NULL) {
|
|
|
|
@ -337,8 +349,8 @@ int saveCandidats(ListeCandidats liste, int nbCandidats) {
|
|
|
|
|
|
|
|
|
|
fprintf(fe, "%d", nbCandidats);
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<nbCandidats; i++) {
|
|
|
|
|
Candidat* candidat = liste[i];
|
|
|
|
|
for(i=0; i<nbCandidats; i++) {
|
|
|
|
|
candidat = liste[i];
|
|
|
|
|
|
|
|
|
|
fprintf(fe, "\n%d\n%s\n%s\n%f\t%f\t%f\t%f\n%d",
|
|
|
|
|
candidat->id, candidat->nom, candidat->prenom,
|
|
|
|
@ -346,10 +358,10 @@ int saveCandidats(ListeCandidats liste, int nbCandidats) {
|
|
|
|
|
candidat->moyenneAnglais, candidat->moyenneSpecialite,
|
|
|
|
|
candidat->nbCandidatures);
|
|
|
|
|
|
|
|
|
|
ListeCandidatures listeCandidatures = candidat->listeCandidatures;
|
|
|
|
|
listeCandidatures = candidat->listeCandidatures;
|
|
|
|
|
|
|
|
|
|
for(int j=0; j<candidat->nbCandidatures; j++) {
|
|
|
|
|
Candidature* candidature = listeCandidatures[j];
|
|
|
|
|
for(j=0; j<candidat->nbCandidatures; j++) {
|
|
|
|
|
candidature = listeCandidatures[j];
|
|
|
|
|
fprintf(fe, "\n%s\n%s\n%d\n%d",
|
|
|
|
|
candidature->ville, candidature->departement,
|
|
|
|
|
candidature->decision, candidature->validation);
|
|
|
|
|