From c31f37d944ad689cb488461915d01683325330c4 Mon Sep 17 00:00:00 2001 From: "benjamin.bachelard" Date: Wed, 11 Jan 2023 19:39:58 +0100 Subject: [PATCH] fini parti deux coter benjamin avec creation d'un nouveau .c pour les fonction candidat --- Candidat.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++ Candidat.don | 18 +++++- adminIut.c | 6 +- iut.c | 87 ----------------------------- iut.h | 12 ++-- testIut.c | 6 +- 6 files changed, 185 insertions(+), 98 deletions(-) create mode 100644 Candidat.c diff --git a/Candidat.c b/Candidat.c new file mode 100644 index 0000000..89ec68e --- /dev/null +++ b/Candidat.c @@ -0,0 +1,154 @@ +#include +#include +#include +#include "iut.h" + +//chargement candidat +int chargementcandidat(Candidat *tcandidat[],int tmax){ + int i = 0, j=0; + int nbChoix = 0; + Candidat C; + Choix ch; + FILE *fe1; + fe1=fopen("Candidat.don","r"); + if(fe1==NULL){ + printf("Problème d'ouverture du fichier Candidat"); + return-1; + } + C = lireCandidat(fe1, &nbChoix); + + while(!feof(fe1)){ + tcandidat[i] = (Candidat*)malloc(sizeof(Candidat)); + if(tcandidat[i]==NULL){ + printf("Problème de malloc"); + return -3; + } + *tcandidat[i] = C; + for(j = 0; j < nbChoix; j++){ + + ch = lireChoix(fe1); + tcandidat[i]->lchoix = InsertionCandidat(tcandidat[i]->lchoix, ch.ville, ch.departement, ch.decision, ch.validation); + } + C = lireCandidat(fe1, &nbChoix); + i++; + } + fclose(fe1); + return i; +} + Candidat lireCandidat(FILE *fe1, int *nbChoix){ + Candidat C; + C.lchoix = NULL; + fscanf(fe1,"%d %s %s %f %f %f %f %d", &C.numero, C.nom, C.prenom, &C.note.Francais, &C.note.Maths, &C.note.Anglais, &C.note.special, &C.nb_choix); + *nbChoix=C.nb_choix; + return C; + } + Choix lireChoix(FILE *fe1){ + Choix ch; + fscanf(fe1,"%s %s %d %d", ch.ville, ch.departement, &ch.decision, &ch.validation); + return ch; + } + ListeC InsertionTeteCandidat(ListeC ld, char *ville, char *departement, int decision, int validation){ + Choix *ch; + ch = (Choix*)malloc(sizeof(Choix)); + if(ch==NULL){ + printf("Problème malloc m"); + exit(1);} + strcpy(ch->ville, ville); + strcpy(ch->departement, departement); + ch->decision = decision; + ch->validation = validation; + ch->suivant = ld; + return ch; + } + ListeC InsertionCandidat(ListeC ld, char *ville, char *departement, int decision, int validation){ + if(ld==NULL) + return InsertionTeteCandidat(ld, ville, departement, decision, validation); + if(strcmp(ld->ville, ville)<0) + return InsertionTeteCandidat(ld, ville, departement, decision, validation); + ld->suivant = InsertionCandidat(ld->suivant, ville, departement, decision, validation); + return ld; + } + //affichage Candidat+choix + void affichageCandidatchoix(Candidat *tcandidat[],int n){ + int i; + for(i=0;ilchoix); + } + } + void afficheCandidat(Candidat *tcandidat[], int i){ + printf("\n%d\t", tcandidat[i]->numero); + printf("%s ", tcandidat[i]->nom); + printf("%s\t", tcandidat[i]->prenom); + printf("%.2f\t", tcandidat[i]->note.Francais); + printf("%.2f\t", tcandidat[i]->note.Maths); + printf("%.2f\t", tcandidat[i]->note.Anglais); + printf("%.2f\t", tcandidat[i]->note.special); + printf("%d\n", tcandidat[i]->nb_choix); + } + void affichageListeCandidatchoix(ListeC ld){ + while(ld!=NULL){ + printf("%s\t",ld->ville); + printf("%s\t",ld->departement); + printf("%d\t",ld->decision); + printf("%d\n",ld->validation); + ld = ld->suivant; + } + } +// Menu Candidat +void MenuCandidat(Candidat *tcandidat[],VilleIUT *tiut[],int nc){ + int Achoix, choix, i, j, comp, comp1; + char Ncandidat[30], PNcandidat[30], departement[30]; + printf("\n0-Revenir au menu\t1-Etudiant\t2-departement\n:"); + scanf("\n%d",&Achoix); + while(Achoix>0 && Achoix<3){ + if(Achoix==1){ + // a toi nicolas + } + if(Achoix==2){ + printf("\n0-Revenir au menu\n1-Afficher Info pour un Candidat\n2-Afficher tout les Candidat par departement\n3-Afficher tout les Candidat avec leur information\n:"); + scanf("\n%d",&choix); + while(choix>0 ){ + if(choix==1){ + printf("\nnom du candidat:"); + scanf("%s",Ncandidat); + printf("\nprenom du candidat:"); + scanf("%s",PNcandidat); + for(i=0;inom, Ncandidat); + comp1=strcmp(tcandidat[i]->prenom, PNcandidat); + if(comp==0 && comp1==0){ + afficheCandidat(tcandidat, i); + affichageListeCandidatchoix(tcandidat[i]->lchoix); + } + } + } + if(choix==2){ + printf("\nnom du departement souhaiter :"); + scanf("%s",departement); + for(i=0;ilchoix,departement, nc) ==0){ + afficheCandidat(tcandidat, i); + } + } + } + if(choix==3){ + printf("\n\n\n\t\tTableau Candidat et choix\n"); + affichageCandidatchoix(tcandidat,nc); + } + printf("\nVoulez-vous choisir une autre fonction ? Sinon taper 0 pour valider : "); + scanf("%d%*c",&choix); + } + } + } +} +int rechercheCandidatParDeaprtement(ListeC ld,char *departement, int nc){ + int emp,i=0; + while(ld!=NULL){ + emp = strcmp(departement, ld->departement); + if(emp==0) + return emp; + ld = ld->suivant; + } + return-1; +} diff --git a/Candidat.don b/Candidat.don index 1b654dd..3891d3c 100644 --- a/Candidat.don +++ b/Candidat.don @@ -1,8 +1,20 @@ -226645 Blondeau Nicolas 4 5.5 4 3 +226645 Blondeau Nicolas 4 5.5 4 2 3 Clermont Biologie 0 0 Grenoble Bio-Info 0 0 Aurillac Informatique 0 0 -226584 bachelard benjamin 20 17.5 19 3 +226584 bachelard benjamin 20 17.5 19 19 3 Clermont Informatique 0 0 Grenoble Informatique 0 0 -Aurillac Informatique 0 0 \ No newline at end of file +Aurillac Informatique 0 0 +226584 deni martin 14 11.5 19 14 3 +Clermont Biologie 0 0 +Grenoble Informatique 0 0 +Aurillac Informatique 0 0 +226584 dadi kevin 20 17.5 19 19 3 +Clermont Biologie 0 0 +Grenoble Informatique 0 0 +Aurillac Informatique 0 0 +226584 moto biker 20 17.5 19 19 3 +Clermont Informatique 0 0 +Grenoble Informatique 0 0 +Aurillac Biologie 0 0 diff --git a/adminIut.c b/adminIut.c index 6506afc..3e41e99 100644 --- a/adminIut.c +++ b/adminIut.c @@ -10,7 +10,7 @@ void MenuAdministrateur(VilleIUT *tiut[],int n){ printf("\n0-Revenir au menu\n1-Modifier place\n2-Creer un departement\n3-supprimer un département\n4-Lancer et Arreter la phase de canditature\n5-modifier nom responsable :"); scanf("\n%d",&choix); - while(choix>0){ + while(choix>0 && choix<6){ if(choix==1){ printf("\nVille où se situe le departement à modifier :"); scanf("%s",Vmodif); @@ -206,7 +206,7 @@ int i, k, j; fclose(fe); return-2; } - if(choix==3){ + if(choix==4){ fprintf(fe,"%s %d\n",tiut[i]->ville, tiut[i]->nbDep); while(tiut[i]->ldept!=NULL){ fprintf(fe,"%s ",tiut[i]->ldept->departement); @@ -233,7 +233,7 @@ int i, k, j; fclose(fe2); return-2; } - if(choix==3){ + if(choix==4){ fprintf(fe,"\n%d %s %s %.2f %.2f %.2f %d\n", tcandidat[i]->numero, tcandidat[i]->nom, tcandidat[i]->prenom, tcandidat[i]->note.Francais, tcandidat[i]->note.Maths, tcandidat[i]->note.Anglais, tcandidat[i]->nb_choix); while(tiut[i]->ldept!=NULL){ fprintf(fe,"%s ",tcandidat[i]->lchoix->ville); diff --git a/iut.c b/iut.c index 8618619..eb1deb6 100644 --- a/iut.c +++ b/iut.c @@ -95,90 +95,3 @@ int chargement(VilleIUT *tiut[],int tmax){ printf("%c\n",ld->AouD); ld = ld->suivant;} } -//chargement candidat -int chargementcandidat(Candidat *tcandidat[],int tmax){ - int i = 0, j=0; - int nbChoix = 0; - Candidat C; - Choix ch; - FILE *fe1; - fe1=fopen("Candidat.don","r"); - if(fe1==NULL){ - printf("Problème d'ouverture du fichier Candidat"); - return-1; - } - C = lireCandidat(fe1, &nbChoix); - - while(!feof(fe1)){ - tcandidat[i] = (Candidat*)malloc(sizeof(Candidat)); - if(tcandidat[i]==NULL){ - printf("Problème de malloc"); - return -3; - } - *tcandidat[i] = C; - for(j = 0; j < nbChoix; j++){ - - ch = lireChoix(fe1); - tcandidat[i]->lchoix = InsertionCandidat(tcandidat[i]->lchoix, ch.ville, ch.departement, ch.decision, ch.validation); - } - C = lireCandidat(fe1, &nbChoix); - i++; - } - fclose(fe1); - return i; -} - Candidat lireCandidat(FILE *fe1, int *nbChoix){ - Candidat C; - C.lchoix = NULL; - fscanf(fe1,"%d %s %s %f %f %f %d", &C.numero, C.nom, C.prenom, &C.note.Francais, &C.note.Maths, &C.note.Anglais, &C.nb_choix); - *nbChoix=C.nb_choix; - return C; - } - Choix lireChoix(FILE *fe1){ - Choix ch; - fscanf(fe1,"%s %s %d %d", ch.ville, ch.departement, &ch.decision, &ch.validation); - return ch; - } - ListeC InsertionTeteCandidat(ListeC ld, char *ville, char *departement, int decision, int validation){ - Choix *ch; - ch = (Choix*)malloc(sizeof(Choix)); - if(ch==NULL){ - printf("Problème malloc m"); - exit(1);} - strcpy(ch->ville, ville); - strcpy(ch->departement, departement); - ch->decision = decision; - ch->validation = validation; - ch->suivant = ld; - return ch; - } - ListeC InsertionCandidat(ListeC ld, char *ville, char *departement, int decision, int validation){ - if(ld==NULL) - return InsertionTeteCandidat(ld, ville, departement, decision, validation); - if(strcmp(ld->ville, ville)<0) - return InsertionTeteCandidat(ld, ville, departement, decision, validation); - ld->suivant = InsertionCandidat(ld->suivant, ville, departement, decision, validation); - return ld; - } - //affichage Candidat+choix - void affichageCandidatchoix(Candidat *tcandidat[],int n){ - int i; - for(i=0;inumero); - printf("%s ", tcandidat[i]->nom); - printf("%s\t", tcandidat[i]->prenom); - printf("%.2f\t", tcandidat[i]->note.Francais); - printf("%.2f\t", tcandidat[i]->note.Maths); - printf("%.2f\t", tcandidat[i]->note.Anglais); - printf("%d\n", tcandidat[i]->nb_choix); - affichageListeCandidatchoix(tcandidat[i]->lchoix); - } - } - void affichageListeCandidatchoix(ListeC ld){ - while(ld!=NULL){ - printf("%s\t",ld->ville); - printf("%s\t",ld->departement); - printf("%d\t",ld->decision); - printf("%d\n",ld->validation); - ld = ld->suivant;} - } \ No newline at end of file diff --git a/iut.h b/iut.h index 56d3474..1eaf7d9 100644 --- a/iut.h +++ b/iut.h @@ -7,6 +7,7 @@ typedef struct{ float Francais; float Maths; float Anglais; + float special; }note; typedef struct liste2 { @@ -50,17 +51,20 @@ typedef enum {faux,vrai}Booleen; int rechercheIUT(VilleIUT *tiut[],int n); int rechercheDept(VilleIUT *tiut[], int n); int recherchePlaces(VilleIUT *tiut[], int n); -//Menu administrateur : - + +//Menu administrateur : void MenuAdministrateur(VilleIUT *tiut[],int n); ListeD suppression(ListeD ld,char *departement); ListeD suppressionTete(ListeD ld); - ListeD Enfiler(ListeD D, char *departement, int nbP,char *resp); + ListeD Enfiler(ListeD ld, char *departement, int nbP,char *resp); ListeD ModifinbP(ListeD ld, char departement[30], int MnbP, int n); ListeD ModifiRespon(ListeD ld, char departement[30], char respon[30], int n); ListeD ModifiAouD(ListeD ld, char departement[30], char AouD, int n); - +//Menu Candidat + void MenuCandidat(Candidat *tcandidat[],VilleIUT *tiut[],int nc); + void afficheCandidat(Candidat *tcandidat[], int i); + int rechercheCandidatParDeaprtement(ListeC ld,char *departement, int nc); //recherche //MaillonDept recherche (MaillonDept *Ville,char *departement,char *responsable); diff --git a/testIut.c b/testIut.c index b12b4a1..73898b0 100644 --- a/testIut.c +++ b/testIut.c @@ -21,7 +21,7 @@ int main(){ affichage(tiut,n); printf("\n\n\n\t\tTableau Candidat et choix\n"); affichageCandidatchoix(tcandidat,nc); - printf("\n\nUtilisateur - 1\tAdministrateur - 2\tSauvegarder et quitter - 3\n\n"); + printf("\n\nUtilisateur - 1\tAdministrateur - 2\tMenu Candidat - 3\tSauvegarder et quitter - 4\n\n"); scanf("%d",&choix); if(choix==1){ printf("\nMenu Utilisateur"); @@ -32,6 +32,10 @@ int main(){ MenuAdministrateur(tiut, n); } if(choix==3){ + printf("\nMenu Candidat"); + MenuCandidat(tcandidat, tiut, nc); + } + if(choix==4){ printf(">----------------------------------------<\n\n"); codeErr = fsauvegarde(tiut, tcandidat, n, nc, choix, 200); printf("\tTous les fichiers sauvegardés.\n\n");