|
|
@ -24,6 +24,18 @@ Choix lirechx (void){//Fonction qui va lire les choix de la ville et du departem
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Choix lireC(FILE *fe)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
printf("J'ai bien été scanné\n");
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Candidat lireCandidat(void)//fonction qui lit un candidat sur le clavier
|
|
|
|
Candidat lireCandidat(void)//fonction qui lit un candidat sur le clavier
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -51,42 +63,58 @@ Candidat lireCandidat(void)//fonction qui lit un candidat sur le clavier
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Candidat lireCa(FILE *fe)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
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 = NULL;//initialisation de la liste
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Choix * chargeChoix(Choix *tchoix, TAILLE, nbchx){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Listechx InsertTC(Listechx list, Maillonchx 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.chx;
|
|
|
|
|
|
|
|
mchx->suivchx = list;
|
|
|
|
|
|
|
|
return mchx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Listechx InsertC(Listechx list, Maillonchx m)//insert globalement dans liste de choix
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (list == NULL){return InsertTC(list, m);}
|
|
|
|
|
|
|
|
if (strcmp(list->chx.dptmt, m.chx.dptmt)>0){return InsertTC(list, m);}
|
|
|
|
|
|
|
|
list->suivchx = InsertC(list->suivchx, m);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AffC(Candidat c)
|
|
|
|
void AffC(Candidat c)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("%d", c.nEtu);
|
|
|
|
printf("%d\n", c.nEtu);
|
|
|
|
printf("%s \n %s\n", c.nom, c.prenom);
|
|
|
|
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\n", c.moymat,c.moyfr, c.moyen, c.moyspe);
|
|
|
|
printf("%d\n", c.nbchx);
|
|
|
|
printf("%d\n", c.nbchx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AffCh(Choix c)
|
|
|
|
Candidat lireFich1Cand (FILE * fe){
|
|
|
|
{
|
|
|
|
Candidat cand;
|
|
|
|
printf("%s \n", c.ville);
|
|
|
|
|
|
|
|
printf("%s \n", c.dptmt);
|
|
|
|
fgets(cand.nom, 20, fe);
|
|
|
|
printf("%d \n", c.dec);
|
|
|
|
cand.nom[strlen(cand.nom)-1]= '\0';
|
|
|
|
printf("%d \n", c.valid);
|
|
|
|
|
|
|
|
|
|
|
|
fgets(cand.prenom, 20, fe);
|
|
|
|
|
|
|
|
cand.prenom[strlen(cand.prenom)-1]= '\0';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fscanf(fe, "%f", &cand.moymat);
|
|
|
|
|
|
|
|
fscanf(fe, "%f", &cand.moyfr);
|
|
|
|
|
|
|
|
fscanf(fe, "%f", &cand.moyen);
|
|
|
|
|
|
|
|
fscanf(fe, "%f", &cand.moyspe);
|
|
|
|
|
|
|
|
fscanf(fe, "%d%*c", &cand.nbchx);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return cand;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//######################################### LISTES ##########################################
|
|
|
|
//######################################### LISTES ##########################################
|
|
|
@ -95,11 +123,21 @@ Candidat lireFich1Cand (FILE * fe){
|
|
|
|
|
|
|
|
|
|
|
|
void AffListeCandidat (Listecand l){
|
|
|
|
void AffListeCandidat (Listecand l){
|
|
|
|
|
|
|
|
|
|
|
|
if ( l == NULL) return;
|
|
|
|
if (l == NULL) return;
|
|
|
|
AffC(l->cand);
|
|
|
|
AffC(l->cand);
|
|
|
|
|
|
|
|
if (l->cand.lchx == NULL){printf("whybitch");}
|
|
|
|
|
|
|
|
AffListChoix(l->cand.lchx);
|
|
|
|
AffListeCandidat(l->suivcand);
|
|
|
|
AffListeCandidat(l->suivcand);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AffListChoix(Listechx l)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (l == NULL) return;
|
|
|
|
|
|
|
|
AffCh(l->chx);
|
|
|
|
|
|
|
|
AffListChoix(l->suivchx);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Listecand recherchenom (Listecand l, char *nom ){
|
|
|
|
Listecand recherchenom (Listecand l, char *nom ){
|
|
|
|
if ( l == NULL ){ return l;}
|
|
|
|
if ( l == NULL ){ return l;}
|
|
|
|
if ( strcmp ( l->cand.nom, nom ) == 0) return l;
|
|
|
|
if ( strcmp ( l->cand.nom, nom ) == 0) return l;
|
|
|
@ -118,6 +156,7 @@ Listecand InsertT(Listecand list, Candidat c)//Insert en tête de la liste
|
|
|
|
|
|
|
|
|
|
|
|
c1 = (Mailloncand*)malloc(sizeof(Mailloncand));
|
|
|
|
c1 = (Mailloncand*)malloc(sizeof(Mailloncand));
|
|
|
|
if (c1 == NULL){printf("pb malloc"); exit;}
|
|
|
|
if (c1 == NULL){printf("pb malloc"); exit;}
|
|
|
|
|
|
|
|
c1->cand.nEtu = c.nEtu;
|
|
|
|
strcpy(c1->cand.nom, c.nom);
|
|
|
|
strcpy(c1->cand.nom, c.nom);
|
|
|
|
strcpy(c1->cand.prenom, c.prenom);
|
|
|
|
strcpy(c1->cand.prenom, c.prenom);
|
|
|
|
c1->cand.moymat = c.moymat;
|
|
|
|
c1->cand.moymat = c.moymat;
|
|
|
@ -125,9 +164,9 @@ Listecand InsertT(Listecand list, Candidat c)//Insert en tête de la liste
|
|
|
|
c1->cand.moyen = c.moyen;
|
|
|
|
c1->cand.moyen = c.moyen;
|
|
|
|
c1->cand.moyspe = c.moyspe;
|
|
|
|
c1->cand.moyspe = c.moyspe;
|
|
|
|
c1->cand.nbchx = c.nbchx;
|
|
|
|
c1->cand.nbchx = c.nbchx;
|
|
|
|
|
|
|
|
c1->cand.lchx = c.lchx;
|
|
|
|
c1->suivcand = list;
|
|
|
|
c1->suivcand = list;
|
|
|
|
return c1;
|
|
|
|
return c1;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -139,41 +178,51 @@ Listecand Insert(Listecand list, Candidat c)//insert globalement
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Chargementlistecandidat( Mailloncand *cand, char *nameFile, int *n)// fonction de chargement de la liste des candidats
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *f;
|
|
|
|
|
|
|
|
Maillon *tmp;
|
|
|
|
|
|
|
|
int n = 0, cpt, nbcand;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
f = fopen(nameFile, "r");
|
|
|
|
|
|
|
|
if (f == NULL){printf("pb ouv file"); return -1;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fscanf(f, "%d", n);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( int j = 0; j < = n; j++ )
|
|
|
|
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;
|
|
|
|
cand = (Mailloncand *)malloc(sizeof(Mailloncand));
|
|
|
|
fscanf(fe, "%d %s%*c", &Ca.nEtu, Ca.nom);
|
|
|
|
if (cand == NULL){printf("pb malloc");exit();}
|
|
|
|
fgets(Ca.prenom, 31, fe);
|
|
|
|
|
|
|
|
Ca.prenom[strlen(Ca.prenom)-1]= '\0';
|
|
|
|
fscanf(f, " %d %s %s %f %f %f %f %d ", &cand->cand.nEtu, cand->cand.nom, cand->cand.prenom, &cand->cand.moymat, &cand->cand.moyfr, &cand->cand.moyen, &cand->cand.moyspe, &cpt);
|
|
|
|
fscanf(fe,"%f %f %f %f %d%*c", &Ca.moymat, &Ca.moyfr, &Ca.moyen, &Ca.moyspe, &Ca.nbchx);
|
|
|
|
|
|
|
|
Ca.lchx=NULL;
|
|
|
|
for (cpt; cpt > 0; cpt--)
|
|
|
|
|
|
|
|
|
|
|
|
for (cpt = Ca.nbchx; cpt >= 1; cpt--)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Maillonchx *chx;
|
|
|
|
printf("je passe et je marche\n");
|
|
|
|
chx = (Maillonchx*)malloc(sizeof(Maillonchx));//création du maillon
|
|
|
|
Maillonchx chx;
|
|
|
|
if (chx == NULL){printf("pb malloc"); exit;}
|
|
|
|
Choix c;
|
|
|
|
lireM(f, chx);//lire le maillon avec la fonction plus haut
|
|
|
|
c = lireC(fe);//lire le maillon avec la fonction plus haut
|
|
|
|
chx->ldept = Insert(tmp->lchx, chx);//insert le maillon à sa bonne place
|
|
|
|
chx.chx = c;//le choix du maillon est celui lu au dessus
|
|
|
|
|
|
|
|
Ca.lchx = InsertC(Ca.lchx, chx);//insert le maillon à sa bonne place
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
lC = Insert(lC, Ca);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
return lC;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void testchgt(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int nbC = 0;
|
|
|
|
|
|
|
|
Listecand lC=NULL;
|
|
|
|
|
|
|
|
FILE *fe;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fe=fopen("part2.don", "r");
|
|
|
|
|
|
|
|
if (fe == NULL){printf("pb ouv file"); return;}
|
|
|
|
|
|
|
|
lC = Chargementlistecandidat(fe, lC, &nbC);
|
|
|
|
|
|
|
|
AffListeCandidat(lC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void test (void){
|
|
|
|
void test (void){
|
|
|
|
|
|
|
|
|
|
|
|
int menu1, menugest1, numet;
|
|
|
|
int menu1, menugest1, numet;
|
|
|
|