|
|
@ -2,3 +2,125 @@
|
|
|
|
#include<stdio.h>
|
|
|
|
#include<stdio.h>
|
|
|
|
#include<string.h>
|
|
|
|
#include<string.h>
|
|
|
|
#include"part3.h"
|
|
|
|
#include"part3.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Choix lireC(FILE *fe)//fonction extraite de la partie 2
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Choix c;
|
|
|
|
|
|
|
|
fscanf(fe, "%s%*c", c.ville);
|
|
|
|
|
|
|
|
fgets(c.dptmt, 26, fe);
|
|
|
|
|
|
|
|
c.dptmt[strlen(c.dptmt)-1]= '\0';
|
|
|
|
|
|
|
|
fscanf(fe, "%d %d%*c", &c.dec, &c.valid);
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Listechx InsertTC(Listechx list, Choix m)//Insert en tête de la liste
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Maillonchx *mchx;
|
|
|
|
|
|
|
|
mchx = (Maillonchx*)malloc(sizeof(Maillonchx));
|
|
|
|
|
|
|
|
if (mchx == NULL){printf("pb malloc"); exit(-1);}
|
|
|
|
|
|
|
|
mchx->chx = m;
|
|
|
|
|
|
|
|
mchx->suivchx = list;
|
|
|
|
|
|
|
|
return mchx;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Listechx InsertC(Listechx list, Choix m)//insert globalement dans liste de choix
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (list == NULL){return InsertTC(list, m);}
|
|
|
|
|
|
|
|
if (strcmp(list->chx.dptmt, m.dptmt)>0){return InsertTC(list, m);}
|
|
|
|
|
|
|
|
list->suivchx = InsertC(list->suivchx, m);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Listecand InsertT(Listecand list, Candidat c)//Insert en tête de la liste
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Mailloncand *c1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c1 = (Mailloncand*)malloc(sizeof(Mailloncand));
|
|
|
|
|
|
|
|
if (c1 == NULL){printf("pb malloc"); exit;}
|
|
|
|
|
|
|
|
c1->cand.nEtu = c.nEtu;
|
|
|
|
|
|
|
|
strcpy(c1->cand.nom, c.nom);
|
|
|
|
|
|
|
|
strcpy(c1->cand.prenom, c.prenom);
|
|
|
|
|
|
|
|
c1->cand.moymat = c.moymat;
|
|
|
|
|
|
|
|
c1->cand.moyfr = c.moyfr;
|
|
|
|
|
|
|
|
c1->cand.moyen = c.moyen;
|
|
|
|
|
|
|
|
c1->cand.moyspe = c.moyspe;
|
|
|
|
|
|
|
|
c1->cand.noteDoss = c.noteDoss;
|
|
|
|
|
|
|
|
c1->cand.nbchx = c.nbchx;
|
|
|
|
|
|
|
|
c1->cand.lchx = c.lchx;
|
|
|
|
|
|
|
|
c1->suivcand = list;
|
|
|
|
|
|
|
|
return c1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Listecand Insert(Listecand list, Candidat c)//insert globalement
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (list == NULL){return InsertT(list, c);}
|
|
|
|
|
|
|
|
if (strcmp(list->cand.nom, c.nom)>0){return InsertT(list, c);}
|
|
|
|
|
|
|
|
list->suivcand = Insert(list->suivcand, c);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Listecand Chargementlistecandidat(FILE *fe, Listecand lC, int *nbC)// fonction de chargement de la liste des candidats
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int cpt, j;
|
|
|
|
|
|
|
|
fscanf(fe, "%d", nbC);
|
|
|
|
|
|
|
|
for (j = 1; j <= *nbC; j++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Candidat Ca;
|
|
|
|
|
|
|
|
fscanf(fe, "%d %s%*c", &Ca.nEtu, Ca.nom);
|
|
|
|
|
|
|
|
fgets(Ca.prenom, 31, 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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (cpt = Ca.nbchx; cpt >= 1; cpt--)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Choix c;
|
|
|
|
|
|
|
|
c = lireC(fe);//lire le maillon avec la fonction plus haut
|
|
|
|
|
|
|
|
Ca.lchx = InsertC(Ca.lchx, c);//insert le maillon à sa bonne place
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
lC = Insert(lC, Ca);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fe);
|
|
|
|
|
|
|
|
return lC;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Save(Listecand lC, int nbC)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *fs;
|
|
|
|
|
|
|
|
fs=fopen("part2.don", "w");
|
|
|
|
|
|
|
|
if (fs == NULL){printf("pb ouv fichier part2.don\n");exit(-1);}
|
|
|
|
|
|
|
|
int cpt;
|
|
|
|
|
|
|
|
fprintf(fs, "%d\n", nbC);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
saveC(lC, fs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void saveC(Listecand lC, FILE *fs)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (lC == NULL)return;
|
|
|
|
|
|
|
|
fprintf(fs, "%d\n", lC->cand.nEtu);
|
|
|
|
|
|
|
|
fprintf(fs, "%s\n", lC->cand.nom);
|
|
|
|
|
|
|
|
fprintf(fs, "%s\n", lC->cand.prenom);
|
|
|
|
|
|
|
|
fprintf(fs, "%.2f\t %.2f\t %.2f\t %.2f\t %.2f\n", lC->cand.moymat, lC->cand.moyfr, lC->cand.moyen, lC->cand.moyspe, lc->cand.noteDoss);
|
|
|
|
|
|
|
|
fprintf(fs, "%d\n", lC->cand.nbchx);
|
|
|
|
|
|
|
|
saveChx(lC->cand.lchx, fs);
|
|
|
|
|
|
|
|
saveC(lC->suivcand, fs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void saveChx(Listechx lCh, FILE *fs)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (lCh == NULL)return;
|
|
|
|
|
|
|
|
fprintf(fs, "%s\n", lCh->chx.ville);
|
|
|
|
|
|
|
|
fprintf(fs, "%s\n", lCh->chx.dptmt);
|
|
|
|
|
|
|
|
fprintf(fs, "%d\n", lCh->chx.dec);
|
|
|
|
|
|
|
|
fprintf(fs, "%d\n", lCh->chx.valid);
|
|
|
|
|
|
|
|
saveChx(lCh->suivchx, fs);
|
|
|
|
|
|
|
|
}
|
|
|
|