You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
6.0 KiB
165 lines
6.0 KiB
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#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;i<n;i++){
|
|
afficheCandidat(tcandidat, i);
|
|
affichageListeCandidatchoix(tcandidat[i]->lchoix);
|
|
}
|
|
}
|
|
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;i<nc;i++){
|
|
comp=strcmp(tcandidat[i]->nom, 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;i<nc;i++){
|
|
if(rechercheCandidatParDeaprtement(tcandidat[i]->lchoix,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;
|
|
}
|
|
int rechercheCandidatParVille(ListeC ld,char *departement ,char *Ville, int nc){
|
|
int emp,emp1,i=0;
|
|
while(ld!=NULL){
|
|
emp = strcmp(Ville, ld->ville);
|
|
emp1 = strcmp(departement, ld->departement);
|
|
if(emp==0 && emp1==0)
|
|
return emp;
|
|
ld = ld->suivant;
|
|
}
|
|
return-1;
|
|
} |