part 3 done

master
lolax 2 years ago
parent 53cac43145
commit 2d052620fb

@ -80,7 +80,7 @@ Listecand Chargementlistecandidat(FILE *fe, Listecand lC, int *nbC)// fonction d
{ {
Candidat Ca; Candidat Ca;
fscanf(fe, "%d %s%*c", &Ca.nEtu, Ca.nom); 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'; 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); fscanf(fe,"%f %f %f %f %f %d%*c", &Ca.moymat, &Ca.moyfr, &Ca.moyen, &Ca.moyspe, &Ca.noteDoss, &Ca.nbchx);
Ca.lchx=NULL; Ca.lchx=NULL;
@ -93,7 +93,6 @@ Listecand Chargementlistecandidat(FILE *fe, Listecand lC, int *nbC)// fonction d
} }
lC = Insert(lC, Ca); lC = Insert(lC, Ca);
} }
fclose(fe);
return lC; 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 void RespAdmin(void)//fonction dédiée au responsable d'admission
{ {
int nbC = 0, nbP; int nbC = 0, nbP;
float noteMin; float noteMin, note;
char nom[26], prenom[26];
Listecand lC=NULL; 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; char rep;
FILE *fe; FILE *fe;
fe=fopen("part3.don", "r");//ouverture fichier fe=fopen("part3.don", "r");//ouverture fichier
if (fe == NULL){printf("pb ouv file"); return;} if (fe == NULL){printf("pb ouv file"); return;}
lC = Chargementlistecandidat(fe, lC, &nbC); 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"); 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 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 printf("Quel est le nom du candidat ?\nNom : \t");
return; 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", &note);
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"); printf("Quelle est la note minimale d'admission souhaitée ?\nNote :\t");
scanf("%f", &noteMin);//on récupère le note minimale requise pour être accepté ou en liste d'attente scanf("%f", &noteMin);//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"); 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 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);//fonction qui maj dec du jury
MajDecJury(lC, nbC, nbP); 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 fclose(fA);
//save séparément fclose(fW);
} }
////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////
@ -241,7 +327,7 @@ void AffC(Candidat c)
{ {
printf("%d\n", c.nEtu); printf("%d\n", c.nEtu);
printf("%s\n%s\n", c.nom, c.prenom); 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); printf("%d\n", c.nbchx);
} }
@ -258,7 +344,6 @@ void AffListeCandidat (Listecand l){
if (l == NULL) return; if (l == NULL) return;
AffC(l->cand); AffC(l->cand);
if (l->cand.lchx == NULL){printf("whybitch");}
AffListChoix(l->cand.lchx); AffListChoix(l->cand.lchx);
AffListeCandidat(l->suivcand); AffListeCandidat(l->suivcand);
} }

@ -1,6 +1,6 @@
typedef struct { typedef struct {
char ville[20];//ville choisie char ville[26];//ville choisie
char dptmt[20];//département choisi char dptmt[26];//département choisi
int dec;//décision du choix int dec;//décision du choix
int valid;//validation du candidat int valid;//validation du candidat
}Choix; }Choix;
@ -16,8 +16,8 @@ typedef Maillonchx * Listechx;
typedef struct { typedef struct {
int nEtu;//numéro d'étudiant int nEtu;//numéro d'étudiant
char nom[20];//nom de l'étudiant char nom[26];//nom de l'étudiant
char prenom[20];//prénom de l'étudiant char prenom[26];//prénom de l'étudiant
float moymat;//moyenne en maths float moymat;//moyenne en maths
float moyfr;//moyenne en français float moyfr;//moyenne en français
float moyen;//moyenne en anglais float moyen;//moyenne en anglais
@ -53,3 +53,7 @@ void AffCh(Choix c);
void AffListeCandidat (Listecand l); void AffListeCandidat (Listecand l);
void AffListChoix(Listechx l); void AffListChoix(Listechx l);
void MajDecJury(Listecand lC, int nbC, int nbAcc);//mise à jour de la décision du jury 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

BIN
test

Binary file not shown.
Loading…
Cancel
Save