diff --git a/part2.don b/part2.don index 8b1a8c5..547be0e 100644 --- a/part2.don +++ b/part2.don @@ -2,7 +2,7 @@ 36 Dupont Jeannine -10.20 15.65 12.45 18.00 12.00 +10.20 15.65 12.45 18.00 2 Clermont-Ferrand Informatique @@ -15,7 +15,7 @@ Informatique 35 Durand Jean Jacques -15.75 12.25 9.50 17.00 11.00 +15.75 12.25 9.50 17.00 3 Aurillac Bio-Informatique @@ -32,7 +32,7 @@ Informatique 38 Henry Bertrand -5.20 14.65 11.23 14.00 9.50 +5.20 14.65 11.23 14.00 2 Clermont-Ferrand Informatique @@ -45,7 +45,7 @@ Informatique 37 Thérèse Francoise -10.50 12.65 14.45 16.00 18.00 +10.50 12.65 14.45 16.00 1 Clermont-Ferrand Bio-Informatique diff --git a/part3.c b/part3.c index 08af5eb..d471174 100644 --- a/part3.c +++ b/part3.c @@ -63,6 +63,14 @@ Listecand Insert(Listecand list, Candidat c)//insert globalement return list; } +Listecand InsertN(Listecand list, Candidat c)//insert globalement en fonction de la note +{ + if (list == NULL){return InsertT(list, c);} + if (list->cand.noteDoss > c.noteDoss){return InsertT(list, c);} + list->suivcand = InsertN(list->suivcand, c); + return list; +} + Listecand Chargementlistecandidat(FILE *fe, Listecand lC, int *nbC)// fonction de chargement de la liste des candidats { @@ -91,31 +99,34 @@ Listecand Chargementlistecandidat(FILE *fe, Listecand lC, int *nbC)// fonction d -void Save(Listecand lC, int nbC) +void Save(Listecand lC, int nbC)//fonction de sauvegarde globale { FILE *fs; - fs=fopen("part2.don", "w"); + //FILE *fs2; + fs=fopen("part3.don", "w"); if (fs == NULL){printf("pb ouv fichier part2.don\n");exit(-1);} - int cpt; fprintf(fs, "%d\n", nbC); + //fs2=fopen("partatt.don", "w"); + //if (fs2 == NULL){printf("pb ouv fichier part2.don\n");exit(-1);} saveC(lC, fs); + //saveC(lC2, fs2); } -void saveC(Listecand lC, FILE *fs) +void saveC(Listecand lC, FILE *fs)//sauvegarde un candidat { if (lC == NULL)return; fprintf(fs, "%d\n", lC->cand.nEtu); fprintf(fs, "%s\n", lC->cand.nom); fprintf(fs, "%s\n", lC->cand.prenom); - fprintf(fs, "%.2f\t %.2f\t %.2f\t %.2f\t %.2f\n", lC->cand.moymat, lC->cand.moyfr, lC->cand.moyen, lC->cand.moyspe, lc->cand.noteDoss); + fprintf(fs, "%.2f\t %.2f\t %.2f\t %.2f\t %.2f\n", lC->cand.moymat, lC->cand.moyfr, lC->cand.moyen, lC->cand.moyspe, lC->cand.noteDoss); fprintf(fs, "%d\n", lC->cand.nbchx); saveChx(lC->cand.lchx, fs); saveC(lC->suivcand, fs); } -void saveChx(Listechx lCh, FILE *fs) +void saveChx(Listechx lCh, FILE *fs)//sauvegardetous les choix d'un candidat { if (lCh == NULL)return; fprintf(fs, "%s\n", lCh->chx.ville); @@ -124,3 +135,138 @@ void saveChx(Listechx lCh, FILE *fs) fprintf(fs, "%d\n", lCh->chx.valid); saveChx(lCh->suivchx, fs); } + + +Listechx searchChx(Listechx lchx, char *ville, char *dptmt) +{ + if (lchx == NULL){return lchx;} + if (strcmp(lchx->chx.ville, ville)==0 && strcmp(lchx->chx.dptmt, dptmt)==0)return lchx; + return searchChx(lchx->suivchx, ville, dptmt); +} + + +Listecand AcceptedOrWait(Listecand lC, int *nbC, float noteMin)//créée une liste de candidat en fonction de la note minimum à avoir +{ + Listecand newlC=NULL;//la nouvelle liste en question + Listechx found;//pour la recherche si le candidat a le département informatique de Clermont + int cpt, i = 0; + for (cpt = 0; cpt < *nbC; cpt++)//en passant par tous les candidats + { + found = searchChx(lC->cand.lchx, "Clermont-Ferrand", "Informatique"); + if (lC->cand.noteDoss >= noteMin && found != NULL)//on check s'ils ont la note d'étude de dossier requise et qu'ils ont une candidature informatique clermont + { + newlC = InsertN(newlC, lC->cand);//si oui on les ajoute + i+=1;//et comme on a une nouvelle liste on les recompte + } + lC = lC->suivcand;//on passe au suivant peu importe ce qu'il arrive + } + *nbC = i; + return newlC; +} + + +void MajDecJury(Listecand lC, int nbC, int nbAcc) +{ + int cpt; + if (nbC > nbAcc)//si le nombre de candidats est supérieur ou égal au nombre max de personnes mises en "accepté" + { + for (cpt = 0; cpt < nbAcc; cpt++)//tous les acceptés + { + Listechx iutclinf; + iutclinf = searchChx(lC->cand.lchx, "Clermont-Ferrand", "Informatique"); + iutclinf->chx.dec = 1; + lC = lC->suivcand; + } + for (cpt; cpt < nbC; cpt ++)//la liste d'attente + { + Listechx iutclinf; + iutclinf = searchChx(lC->cand.lchx, "Clermont-Ferrand", "Informatique"); + iutclinf->chx.dec = 2; + lC = lC->suivcand; + } + } + else + { + for (cpt = 0; cpt < nbC; cpt++)//tous acceptés si il y a moins de candidatures que de places + { + Listechx iutclinf; + iutclinf = searchChx(lC->cand.lchx, "Clermont-Ferrand", "Informatique"); + iutclinf->chx.dec = 1; + lC = lC->suivcand; + } + } +} + + +void RespAdmin(void)//fonction dédiée au responsable d'admission +{ + int nbC = 0, nbP; + float noteMin; + Listecand lC=NULL; + char rep; + + FILE *fe; + fe=fopen("part3.don", "r");//ouverture fichier + if (fe == NULL){printf("pb ouv file"); return;} + lC = Chargementlistecandidat(fe, lC, &nbC); + + printf("Souhaitez vous modifier les notes de dossier déjà renseignées ?(O/N)\nATTENTION \nCe sera la seule fois où vous pourrez modifier ces notes\n"); + scanf("%c", &rep);//on récupère la réponse de la volonté du responsable des adimissions + if (rep == 'O') + { + //fonction de modifs de notes à faire + return; + } + //faire le tri des candidats en fonction de leurs noteDoss + //lC=nouveau + maj nbC + printf("Quelle est la note minimale d'admission souhaitée ?\nNote :\t"); + scanf("%f", ¬eMin);//on récupère le note minimale requise pour être accepté ou en liste d'attente + + lC = AcceptedOrWait(lC, &nbC, noteMin);//on créé la nouvelle liste des candidats sélectionnés par note + + printf("Quel est le nombre de places disponibles ?\n"); + scanf("%d", &nbP);//on récupère le nombre qu'il peut y avoir d'acceptés pour savoir qui sera accepté et qui sera en attente + + //appeler fonction qui maj dec du jury + MajDecJury(lC, nbC, nbP); + + //appeler fonction qui split en deux + //save séparément +} + +////////////////////////////////////////////////////////////////////////////////////////////////////// +//histoire d'avoir un AFFICHAGE + +void AffC(Candidat c) +{ + printf("%d\n", c.nEtu); + printf("%s\n%s\n", c.nom, c.prenom); + printf("%.2f\t%.2f\t%.2f\t%.2f\n", c.moymat,c.moyfr, c.moyen, c.moyspe); + printf("%d\n", c.nbchx); +} + +void AffCh(Choix c) +{ + printf("%s \n", c.ville); + printf("%s \n", c.dptmt); + printf("%d \n", c.dec); + printf("%d \n", c.valid); +} + + +void AffListeCandidat (Listecand l){ + + if (l == NULL) return; + AffC(l->cand); + if (l->cand.lchx == NULL){printf("whybitch");} + AffListChoix(l->cand.lchx); + AffListeCandidat(l->suivcand); +} + + +void AffListChoix(Listechx l) +{ + if (l == NULL) return; + AffCh(l->chx); + AffListChoix(l->suivchx); +} diff --git a/part3.don b/part3.don new file mode 100644 index 0000000..2810430 --- /dev/null +++ b/part3.don @@ -0,0 +1,53 @@ +4 +36 +Dupont +Jeannine +10.20 15.65 12.45 18.00 13.00 +2 +Clermont-Ferrand +Informatique +0 +0 +Aurillac +Informatique +0 +0 +35 +Durand +Jean Jacques +15.75 12.25 9.50 17.00 9.50 +3 +Aurillac +Bio-Informatique +0 +0 +Clermont-Ferrand +Informatique +0 +0 +Grenoble +Informatique +0 +0 +38 +Henry +Bertrand +5.20 14.65 11.23 14.00 12.00 +2 +Clermont-Ferrand +Informatique +0 +0 +Aurillac +Informatique +0 +0 +37 +Thérèse +Francoise +10.50 12.65 14.45 16.00 18.00 +1 +Clermont-Ferrand +Bio-Informatique +0 +0 diff --git a/part3.h b/part3.h index e784c9b..ccfbcbc 100644 --- a/part3.h +++ b/part3.h @@ -34,3 +34,22 @@ typedef struct Mailloncand{ }Mailloncand; typedef Mailloncand * Listecand; + + +Choix lireC(FILE *fe);//fonction extraite de la partie 2 +Listechx InsertTC(Listechx list, Choix m);//Insert en tête de la liste +Listechx InsertC(Listechx list, Choix m);//insert globalement dans liste de choix +Listecand InsertT(Listecand list, Candidat c);//Insert en tête de la liste +Listecand Insert(Listecand list, Candidat c);//insert globalement +Listecand InsertN(Listecand list, Candidat c);//insert globalement en fonction de la note +Listecand Chargementlistecandidat(FILE *fe, Listecand lC, int *nbC);// fonction de chargement de la liste des candidats +Listecand AcceptedOrWait(Listecand lC, int *nbC, float noteMin); +void Save(Listecand lC, int nbC);//fonction de sauvegarde globale +void saveC(Listecand lC, FILE *fs);//sauvegarde un candidat +void saveChx(Listechx lCh, FILE *fs);//sauvegarde tous les choix d'un candidat +void RespAdmin(void);//fonction dédiée au responsable d'admission +void AffC(Candidat c); +void AffCh(Choix c); +void AffListeCandidat (Listecand l); +void AffListChoix(Listechx l); +void MajDecJury(Listecand lC, int nbC, int nbAcc);//mise à jour de la décision du jury diff --git a/tpart3.c b/tpart3.c index 53c2fd9..c3f40cf 100644 --- a/tpart3.c +++ b/tpart3.c @@ -2,3 +2,9 @@ #include #include #include"part3.h" + +int main(void) +{ + RespAdmin(); + return 0; +}