|
|
|
@ -29,6 +29,81 @@ int testVideChx (Filechx f){// fonction test si la Filechx est vide return 1 sin
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Candidat lireCa(FILE *fe)// lit un candidat dans un fichier
|
|
|
|
|
{
|
|
|
|
|
Candidat c;//candidat que l'on retournera
|
|
|
|
|
Choix chx;//pour la création de maillons
|
|
|
|
|
int cpt = 0;//qui servira à compter le nombre de choix
|
|
|
|
|
fscanf(fe,"%d", c.nEtu);
|
|
|
|
|
fgets(c.nom, 23, fe);
|
|
|
|
|
c.nom[strlen(c.nom)-1]= '\0';
|
|
|
|
|
fgets(c.prenom, 23, fe);
|
|
|
|
|
c.prenom[strlen(c.prenom)-1]= '\0';
|
|
|
|
|
fscanf(fe, "%f %f %f %f %d%*c", c.moymat, c.moyfr, c.moyen, c.moyspe, c.nbchx);
|
|
|
|
|
c.lchx = init();//initialisation de la liste
|
|
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
// FAIRE LECTURE CHOIX POUR METTRE EN PARAMETRE PLUTOT QUE LE FE
|
|
|
|
|
|
|
|
|
|
Filechx enfilechx ( Filechx f , File *fe){//fonction enfile un maillon choix en fin de file Choix
|
|
|
|
|
Maillonchx *mch;
|
|
|
|
|
int nbchoix, i, nbcand, numCand;
|
|
|
|
|
char nom[30], prenom[30];
|
|
|
|
|
float nmat, nfr, nen, nspe, nDoss;
|
|
|
|
|
|
|
|
|
|
mch = (Maillonchx*) malloc ( sizeof (Maillonchx));
|
|
|
|
|
if ( mch == NULL ){
|
|
|
|
|
printf("Probleme malloc");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
fscanf ( fe , "%d %d %s %s %f %f %f %f %f %d", &nbcand, &numCand, nom, prenom, &nmat, &nfr, &nen, &nspe, &nDoss, &nbchoix );
|
|
|
|
|
for ( i = 0 ; i < nbchoix ; i++ ){
|
|
|
|
|
fscanf( fe, "%s %s %d %d", mch->chx.ville, mch->chx.dptmt, mch->chx.dec, mch->chx.valid);
|
|
|
|
|
if ( testVideChx (f)){
|
|
|
|
|
f.ttchx = mch;
|
|
|
|
|
f.kechx = mch;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
f.kechx->suivchx = mch;
|
|
|
|
|
f.kechx = mch
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FAIRE LECTURE CANDIDAT POUR METTRE EN PARALLELE
|
|
|
|
|
|
|
|
|
|
Filecand enfilecand (Filecand f, FILE *fe){// fonction enfile un maillon cand en fin de file Candidat
|
|
|
|
|
Mailloncand *mc;
|
|
|
|
|
int nbchoix, i nbcand;
|
|
|
|
|
|
|
|
|
|
mc = (Mailloncand*) malloc (sizeof (Mailloncand));
|
|
|
|
|
if ( mc == NULL ){
|
|
|
|
|
printf("probleme malloc");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
mc->cand = lireCa (fe);
|
|
|
|
|
//fscanf(fe, "%d %d %s %s %f %f %f %f %f %d",&nbcand, &mc->cand.nEtu, mc->cand.nom, mc->cand.prenom, &mc->cand.moymat, &mc->cand.moyfr, &mc->cand.moyen, &mc->cand.moyspe, &mc->cand.noteDoss, &nbchoix);
|
|
|
|
|
mc->suivcand = NULL;
|
|
|
|
|
if ( testVideCand (f)){
|
|
|
|
|
f.ttcand = mc;
|
|
|
|
|
f.kecand = mc;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
f.kecand->suivant = mc;
|
|
|
|
|
f.kecand = mc;
|
|
|
|
|
}
|
|
|
|
|
return f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int chargement (void){// chargement des files cand et chx
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Choix lireC(FILE *fe)//fonction extraite de la partie 2
|
|
|
|
|
{
|
|
|
|
|
Choix c;
|
|
|
|
@ -135,32 +210,15 @@ Listecand Chargementlistecandidat(FILE *fe, Listecand lC, int *nbC)// fonction d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test (void){
|
|
|
|
|
FILE *fe;
|
|
|
|
|
|
|
|
|
|
fe = fopen( "part4.don", "r");
|
|
|
|
|
if ( fe == NULL ){
|
|
|
|
|
printf(" probleme d'ouverture de fichier");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test (void {
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|