partie 2 finie

master
Roxane ROSSETTO 2 years ago
parent 35e89fe502
commit 19aae20518

@ -107,6 +107,10 @@ void AffC(Candidat c)
printf("%d\n", c.nbchx);
}
void affnomcand (Candidat c){
printf("%s\n%s\n", c.nom, c.prenom);
}
void AffCh(Choix c)
{
printf("%s \n", c.ville);
@ -128,6 +132,11 @@ void AffListeCandidat (Listecand l){
AffListeCandidat(l->suivcand);
}
void AffCandid (Listecand l){
if ( l == NULL ) { printf("Pas de candidat\n"); return;}
affnomcand( l->cand);
AffCandid ( l->suivcand);
}
void AffListChoix(Listechx l)
{
@ -155,6 +164,12 @@ Listechx recherchechx (Listechx l, char *nom )//recherche du nom de département
return recherchechx (l->suivchx, nom );
}
Listecand recherchevilledpt ( Listecand l, char *ville, char *dpt){
if ( l == NULL ) return l;
if ( strcmp( l->cand.lchx->chx.ville , ville ) == 0 && strcmp( l->cand.lchx->chx.dptmt, dpt) == 0) return l;
return recherchevilledpt ( l->suivcand, ville, dpt);
}
Listechx majchoix (Listechx chx, Choix c){//Mise à jour du de la liste choix en modifiant un maillon
strcpy(chx->chx.ville, c.ville);
@ -328,7 +343,6 @@ void test (void){
printf("Entrer le nom du departement de l candidature concernée\n");
scanf("%s", nomdpt);
//PROBLEME SUR L'ASSIGNATION DU RESULTAT DE RECHERCHE... J'ARRIVE PAS
l2cand->cand.lchx = recherchechx(l2cand->cand.lchx, nomdpt);
while ( l2cand->cand.lchx->chx.dptmt == NULL){
printf("departement inconnu veuillez saisir à nouveau\n");
@ -356,19 +370,24 @@ void test (void){
}
else if (menu1 == 2){
printf("Entrer le nom du departement dont vous souhaitez afficher les candidats");
scanf("%s", nomdpt);
printf("Entrer le nom de la ville dans laquelle se trouve le departement en question\n");
printf("Entrer le nom de la ville dans laquelle se trouve le departement d'étude\n");
scanf("%s", nomville);
//FAIRE UNE FONCTION DE RECHERCHE RECURSIVE
/*FONCTION AFFICHE (CANDIDATS , VILLE, DEPARTEMENT)
EX : SI L->CHX.VILLE == VILLE && L->CHX.DEPARTEMENT == DEPARTEMENT
ALORS AFFICHE MAILLON CANDIDAT
RETURN AFFICHE CANDIDAT->SUIVANT, VILLE, DEPARTEMENT)
}
printf("Entrer le nom du departement dont vous souhaitez afficher les candidats\n");
scanf("%s", nomdpt);
l2cand = recherchevilledpt ( lcand, nomville, nomdpt);
AffCandid (l2cand);
}
Save(lcand, nbC);
fclose(fe);
}

@ -56,11 +56,14 @@ Listechx InsertC(Listechx list, Choix m);//insertion globale d'un maillon de typ
void AffC(Candidat c);//affichage simple d'un candidat
void AffCh(Choix c);//affichage simple d'un choix
void affnomcand (Candidat c);
void AffListeCandidat (Listecand l);//affiche complet de la liste de candidats
void AffCandid (Listecand l);//affiche que le nom
void AffListChoix(Listechx l);//affichage complet de la liste de choix
Listecand recherchenom (Listecand l, char *nom );//recherche par un nom dans une liste de candidats
Listecand recherchenum (Listecand l, int num);//recherche par le numéro dans une liste de candidats
Listechx recherchechx (Listechx l, char *nom );// recherche par le nom d'un depratement dans une listedederpartement
Listecand recherchevilledpt ( Listecand l, char *ville, char *dpt);//recherche et retour de la liste des candidats ayant postuler a un certain departement
Listechx majchoix (Listechx chx, Choix c);// mise jour d'un choix
Listecand Chargementlistecandidat(FILE *fe, Listecand lC, int *nbC);//chargement du fichier dans une liste de candidats
Listechx suppressionchxT (Listechx l);//Fonction suppression d'un maillon

@ -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", &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");
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");
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);
}

@ -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

BIN
test

Binary file not shown.
Loading…
Cancel
Save