diff --git a/part2.don b/part2.don index f3228e8..547be0e 100644 --- a/part2.don +++ b/part2.don @@ -45,7 +45,7 @@ Informatique 37 Thérèse Francoise -10.50 12.65 14.45 16.00 +10.50 12.65 14.45 16.00 1 Clermont-Ferrand Bio-Informatique diff --git a/part3.c b/part3.c index 53c2fd9..d471174 100644 --- a/part3.c +++ b/part3.c @@ -2,3 +2,271 @@ #include #include #include"part3.h" + +Choix lireC(FILE *fe)//fonction extraite de la partie 2 +{ + Choix c; + fscanf(fe, "%s%*c", c.ville); + fgets(c.dptmt, 26, fe); + c.dptmt[strlen(c.dptmt)-1]= '\0'; + fscanf(fe, "%d %d%*c", &c.dec, &c.valid); + return c; +} + + +Listechx InsertTC(Listechx list, Choix m)//Insert en tête de la liste +{ + Maillonchx *mchx; + mchx = (Maillonchx*)malloc(sizeof(Maillonchx)); + if (mchx == NULL){printf("pb malloc"); exit(-1);} + mchx->chx = m; + mchx->suivchx = list; + return mchx; +} + + +Listechx InsertC(Listechx list, Choix m)//insert globalement dans liste de choix +{ + if (list == NULL){return InsertTC(list, m);} + if (strcmp(list->chx.dptmt, m.dptmt)>0){return InsertTC(list, m);} + list->suivchx = InsertC(list->suivchx, m); + return list; +} + + +Listecand InsertT(Listecand list, Candidat c)//Insert en tête de la liste +{ + Mailloncand *c1; + + c1 = (Mailloncand*)malloc(sizeof(Mailloncand)); + if (c1 == NULL){printf("pb malloc"); exit;} + c1->cand.nEtu = c.nEtu; + strcpy(c1->cand.nom, c.nom); + strcpy(c1->cand.prenom, c.prenom); + c1->cand.moymat = c.moymat; + c1->cand.moyfr = c.moyfr; + c1->cand.moyen = c.moyen; + c1->cand.moyspe = c.moyspe; + c1->cand.noteDoss = c.noteDoss; + c1->cand.nbchx = c.nbchx; + c1->cand.lchx = c.lchx; + c1->suivcand = list; + return c1; +} + + +Listecand Insert(Listecand list, Candidat c)//insert globalement +{ + if (list == NULL){return InsertT(list, c);} + if (strcmp(list->cand.nom, c.nom)>0){return InsertT(list, c);} + list->suivcand = Insert(list->suivcand, c); + 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 +{ + int cpt, j; + fscanf(fe, "%d", nbC); + for (j = 1; j <= *nbC; j++) + { + Candidat Ca; + fscanf(fe, "%d %s%*c", &Ca.nEtu, Ca.nom); + fgets(Ca.prenom, 31, fe); + Ca.prenom[strlen(Ca.prenom)-1]= '\0'; + fscanf(fe,"%f %f %f %f %f %d%*c", &Ca.moymat, &Ca.moyfr, &Ca.moyen, &Ca.moyspe, &Ca.noteDoss, &Ca.nbchx); + Ca.lchx=NULL; + + for (cpt = Ca.nbchx; cpt >= 1; cpt--) + { + Choix c; + c = lireC(fe);//lire le maillon avec la fonction plus haut + Ca.lchx = InsertC(Ca.lchx, c);//insert le maillon à sa bonne place + } + lC = Insert(lC, Ca); + } + fclose(fe); + return lC; +} + + + +void Save(Listecand lC, int nbC)//fonction de sauvegarde globale +{ + FILE *fs; + //FILE *fs2; + fs=fopen("part3.don", "w"); + if (fs == NULL){printf("pb ouv fichier part2.don\n");exit(-1);} + 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)//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, "%d\n", lC->cand.nbchx); + saveChx(lC->cand.lchx, fs); + saveC(lC->suivcand, fs); +} + + +void saveChx(Listechx lCh, FILE *fs)//sauvegardetous les choix d'un candidat +{ + if (lCh == NULL)return; + fprintf(fs, "%s\n", lCh->chx.ville); + fprintf(fs, "%s\n", lCh->chx.dptmt); + fprintf(fs, "%d\n", lCh->chx.dec); + 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 55bdbf5..ccfbcbc 100644 --- a/part3.h +++ b/part3.h @@ -24,7 +24,6 @@ typedef struct { float moyspe;//moyenne en spécialité float noteDoss;//note après étude du dossier int nbchx;//nombre de choix - int statut;//liste d'attente ou non Listechx lchx; }Candidat; @@ -35,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; +}