diff --git a/part3.c b/part3.c index d471174..b343e46 100644 --- a/part3.c +++ b/part3.c @@ -80,7 +80,7 @@ Listecand Chargementlistecandidat(FILE *fe, Listecand lC, int *nbC)// fonction d { Candidat Ca; fscanf(fe, "%d %s%*c", &Ca.nEtu, Ca.nom); - fgets(Ca.prenom, 31, fe); + fgets(Ca.prenom, 26, 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; @@ -93,7 +93,6 @@ Listecand Chargementlistecandidat(FILE *fe, Listecand lC, int *nbC)// fonction d } lC = Insert(lC, Ca); } - fclose(fe); return lC; } @@ -198,27 +197,99 @@ void MajDecJury(Listecand lC, int nbC, int nbAcc) } +Listecand searchCand(Listecand lC, char *nom, char *prenom) +{ + if (lC == NULL)return lC; + if (strcmp(lC->cand.nom, nom)==0 && strcmp(lC->cand.prenom, prenom)==0)return lC; + return searchCand(lC, nom, prenom); +} + + +Listecand MajNote(Listecand lC, char *nom, char *prenom, float newNote) +{ + Listecand c; + c = searchCand(lC, nom, prenom);//recherche du candidat + if (c == NULL) + { + printf("Aucun candidat n'a été trouvé...\n"); + } + else + { + c->cand.noteDoss = newNote; + } + return lC; +} + + +Listecand splitAccepted(Listecand origin) +{ + Listecand lCAcc=NULL; + while (origin != NULL) + { + Listechx iutclinf; + iutclinf = searchChx(origin->cand.lchx, "Clermont-Ferrand", "Informatique"); + if (iutclinf->chx.dec == 1 && iutclinf !=NULL) + { + lCAcc = Insert(lCAcc, origin->cand); + } + origin = origin->suivcand; + } + return lCAcc; +} + +Listecand splitWait(Listecand origin) +{ + Listecand lCW=NULL; + Listechx iutclinf; + iutclinf = searchChx(origin->cand.lchx, "Clermont-Ferrand", "Informatique"); + while (iutclinf->chx.dec == 1 && iutclinf != NULL) + { + origin = origin->suivcand; + if (origin == NULL)break;//on évite le tour de search inutile + iutclinf = searchChx(origin->cand.lchx, "Clermont-Ferrand", "Informatique");//tant qu'ils sont acceptés, on relis le candidat + } + while (iutclinf->chx.dec == 2 && iutclinf != NULL)//si en liste d'attente + { + lCW = Insert(lCW, origin->cand);//insertion dans la liste pour liste d'attente + origin = origin->suivcand; + if (origin == NULL)break;//on évite le tour de search inutile + iutclinf = searchChx(origin->cand.lchx, "Clermont-Ferrand", "Informatique"); + } + return lCW; +} + + void RespAdmin(void)//fonction dédiée au responsable d'admission { int nbC = 0, nbP; - float noteMin; + float noteMin, note; + char nom[26], prenom[26]; Listecand lC=NULL; + Listecand lCAcc=NULL, lCW=NULL;//ce qui servira pour les 2 listes, l'une des acceptés et l'autre des attentes char rep; FILE *fe; fe=fopen("part3.don", "r");//ouverture fichier if (fe == NULL){printf("pb ouv file"); return;} lC = Chargementlistecandidat(fe, lC, &nbC); + fclose(fe); 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') + while (rep == 'O') { - //fonction de modifs de notes à faire - return; + printf("Quel est le nom du candidat ?\nNom : \t"); + scanf("%s%*c", nom); + printf("Quel est le prénom du candidat ?\nPrénom : \t"); + fgets(prenom, 26, stdin); + prenom[strlen(prenom)-1]='\0'; + printf("Quelle sera la nouvelle note ?\nNote : \t"); + scanf("%f%*c", ¬e); + lC = MajNote(lC, nom, prenom, note); + printf("Souhaitez-vous changer/renseigner une autre note ?\n"); + scanf("%c", &rep); } - //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 @@ -227,11 +298,26 @@ void RespAdmin(void)//fonction dédiée au responsable d'admission 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); + MajDecJury(lC, nbC, nbP);//fonction qui maj dec du jury + lCAcc = splitAccepted(lC);//la liste des acceptés + + lCW = splitWait(lC);//la liste d'attente + + + FILE *fA; + FILE *fW; + + fA = fopen("partAcc.don", "w");//ouverture du fichier de sauvegarde des acceptés + if (fA == NULL){printf("pb ouv fichier acc\n"); exit(-1);} + + fW = fopen("partWait.don", "w");//ouverture du fichier de sauvegarde de l'attente + if (fW == NULL){printf("pb ouv fichier wait\n"); exit(-1);} + + saveC(lCAcc, fA);//sauvegarde des acceptés + saveC(lCW, fW);//sauvegarde de l'attente - //appeler fonction qui split en deux - //save séparément + fclose(fA); + fclose(fW); } ////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -241,7 +327,7 @@ 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("%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n", c.moymat,c.moyfr, c.moyen, c.moyspe, c.noteDoss); printf("%d\n", c.nbchx); } @@ -258,7 +344,6 @@ 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); } diff --git a/part3.h b/part3.h index ccfbcbc..43484fb 100644 --- a/part3.h +++ b/part3.h @@ -1,6 +1,6 @@ typedef struct { - char ville[20];//ville choisie - char dptmt[20];//département choisi + char ville[26];//ville choisie + char dptmt[26];//département choisi int dec;//décision du choix int valid;//validation du candidat }Choix; @@ -16,8 +16,8 @@ typedef Maillonchx * Listechx; typedef struct { int nEtu;//numéro d'étudiant - char nom[20];//nom de l'étudiant - char prenom[20];//prénom de l'étudiant + char nom[26];//nom de l'étudiant + char prenom[26];//prénom de l'étudiant float moymat;//moyenne en maths float moyfr;//moyenne en français float moyen;//moyenne en anglais @@ -53,3 +53,7 @@ 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 +Listecand searchCand(Listecand lC, char *nom, char *prenom);//recherche d'un candidat par son nom et prénom +Listecand MajNote(Listecand lC, char *nom, char *prénom, float newNote);//mise à jour de la note de dossier du candidat +Listecand splitAccepted(Listecand origin);//fonction qui retourne la liste des admis +Listecand splitWait(Listecand origin);//fonction qui retourne la liste d'attente diff --git a/test b/test deleted file mode 100644 index 689c844..0000000 Binary files a/test and /dev/null differ