08/01 correction en partie du Chargement de candidature

master
Alexis LAURENT 2 years ago
parent 1786af0464
commit 725fb8f893

101
SAE.c

@ -199,14 +199,33 @@ int gestionMenuAdmin(VilleIUT **tiut, int nbEle)
void global(void) void global(void)
{ {
int tailleL, i; /*int tailleL, i;
VilleIUT** tab; VilleIUT** tab;
char nomFich[20]; char nomFich[20];
strcpy(nomFich,"iut.txt"); strcpy(nomFich,"iut.txt");
printf("charg\n"); printf("charg\n");
tab = chargementVille(nomFich,30,&tailleL); tab = chargementVille(nomFich,30,&tailleL);
printf("\n"); printf("\n");
gestionMenu(tab, tailleL); gestionMenu(tab, tailleL);*/
int tailleL, i = 0;
Candidat** tab;
char nomFich[20];
strcpy(nomFich,"candidature.txt");
printf("charg\n");
tab = chargmentCandid(nomFich, 30, &tailleL);
printf("\n");
while(i < 4)
{
printf("%d %s %s\t",tab[i]->id, tab[i]->idCandIUT->iutCandid, tab[i]->idCandIUT->idCandDept->departement);
i = i + 1;
printf("\n");
afficherCandid(tab[i]->idCandIUT);
}
//tab[0]->idCandIUT = tab[0]->idCandIUT->suiv;
//printf("%s\n", tab[0]->idCandIUT->iutCandid);
tab[0]->idCandIUT->idCandDept = tab[0]->idCandIUT->idCandDept->suiv;
printf("%s\n", tab[0]->idCandIUT->idCandDept->departement);
} }
void AffichageVille(VilleIUT **tiut, int nbEle) void AffichageVille(VilleIUT **tiut, int nbEle)
@ -390,7 +409,7 @@ void MiseAJourNbPlace(VilleIUT **tiut, int nbEle)
if (aux != NULL) if (aux != NULL)
{ {
printf("Ancien nombre de places : %d\n",aux->nbPers); printf("Ancien nombre de places : %d\n",aux->nbPers);
printf("Nouveau nombre de places : ", nouvNbPlace); printf("Nouveau nombre de places : ");
scanf("%d", &nouvNbPlace); scanf("%d", &nouvNbPlace);
aux->nbPers = nouvNbPlace; aux->nbPers = nouvNbPlace;
printf("Mise à jour effectuer avec succès !"); printf("Mise à jour effectuer avec succès !");
@ -460,7 +479,7 @@ void suppressionDept(VilleIUT **tiut, int nbEle)
{ {
MaillonDept *aux; MaillonDept *aux;
char code[30]; char code[30];
int trouve, pos, nbP; int trouve, pos;
while(1) while(1)
{ {
printf("Dans quel IUT voulez-vous supprimer un département : "); printf("Dans quel IUT voulez-vous supprimer un département : ");
@ -493,7 +512,7 @@ void modifChefDept(VilleIUT **tiut, int nbEle)
{ {
MaillonDept *aux; MaillonDept *aux;
char code[30]; char code[30];
int trouve, pos, nbP; int trouve, pos;
while(1) while(1)
{ {
printf("Dans quel IUT voulez-vous modifier le chef de département : "); printf("Dans quel IUT voulez-vous modifier le chef de département : ");
@ -610,7 +629,7 @@ ListeCandidDept ListeCandidDeptvide(void)
return NULL; return NULL;
} }
ListeCandidDept insererEnTeteCandidDept(ListeCandidDept l, char departement[], char deciDept[], int deciCandid) ListeCandidDept insererEnTeteCandidDept(ListeCandidDept l, char departement[], int deciDept, int deciCandid)
{ {
MaillonCandidDept *m; MaillonCandidDept *m;
m = (MaillonCandidDept *)malloc(sizeof(MaillonCandidDept)); m = (MaillonCandidDept *)malloc(sizeof(MaillonCandidDept));
@ -621,7 +640,7 @@ ListeCandidDept insererEnTeteCandidDept(ListeCandidDept l, char departement[], c
} }
strcpy(m->departement, departement); strcpy(m->departement, departement);
m->decisionDept = deciDept; m->decisionDept = deciDept;
m->deciCandid = deciCandid; m->decisionCandid = deciCandid;
m->suiv = l; m->suiv = l;
return m; return m;
} }
@ -648,7 +667,7 @@ ListeCandid insererEnTeteCandid(ListeCandid l, char *ville)
printf("Pb maillon"); printf("Pb maillon");
exit(1); exit(1);
} }
strcpy(ville, l->iutcandid); strcpy(m->iutCandid, ville);
m->suiv = l; m->suiv = l;
return m; return m;
} }
@ -657,9 +676,9 @@ ListeCandid insererCandid(ListeCandid l, char *ville)
{ {
if (l == NULL) if (l == NULL)
return insererEnTeteCandid(l, ville); return insererEnTeteCandid(l, ville);
if (strcmp(ville, l->iutcandid) < 0) if (strcmp(ville, l->iutCandid) < 0)
return insererEnTeteCandid(l, ville); return insererEnTeteCandid(l, ville);
if (strcmp(ville, l->iutcandid) == 0) if (strcmp(ville, l->iutCandid) == 0)
return l; return l;
l->suiv = insererCandid(l->suiv, ville); l->suiv = insererCandid(l->suiv, ville);
return l; return l;
@ -709,9 +728,10 @@ ListeCandid suppressionCandid(ListeCandid l, char *ville)
{ {
if (l == NULL) if (l == NULL)
return l; return l;
if (strcmp(ville, l->iutcandid) < 0) if (strcmp(ville, l->iutCandid) < 0)
return l; return l;
if (strcmp(ville, l->iutcandid) == 0) if (strcmp(ville, l->iutCandid) == 0)
{
while (1) while (1)
{ {
if (l->idCandDept == NULL) if (l->idCandDept == NULL)
@ -719,7 +739,8 @@ ListeCandid suppressionCandid(ListeCandid l, char *ville)
suppressionEnTeteCandidDept(l->idCandDept); suppressionEnTeteCandidDept(l->idCandDept);
} }
return suppressionEnTeteCandid(l); return suppressionEnTeteCandid(l);
l->suiv = suppressionCandid(l->suiv); }
l->suiv = suppressionCandid(l->suiv, ville);
return l; return l;
} }
@ -741,7 +762,7 @@ void afficherCandid(ListeCandid l)
aux = l; aux = l;
while(aux != NULL) while(aux != NULL)
{ {
printf("%s\t",aux->iutcandid); printf("%s\t",aux->iutCandid);
afficherCandidDept(aux->idCandDept); afficherCandidDept(aux->idCandDept);
aux = aux->suiv; aux = aux->suiv;
} }
@ -757,11 +778,11 @@ int longueur(ListeCandid l)
Candidat **chargmentCandid(char *nomFich, int tphys, int *tailleL) Candidat **chargmentCandid(char *nomFich, int tphys, int *tailleL)
{ {
int i = 0, nbCandidat, nbCandid; int i = 0, j = 0, nbCandidat, nbIUT, nbDept;
FILE *flot; FILE *flot;
Candidat **tcandid; Candidat **tcandid;
tcandid = (Candidat *)malloc(sizeof(Candidat) * tphys); tcandid = (Candidat **)malloc(sizeof(Candidat *) * tphys);
if (tabV == NULL) if (tcandid == NULL)
{ {
printf("Erreur malloc tcandid !\n"); printf("Erreur malloc tcandid !\n");
exit(1); exit(1);
@ -780,21 +801,51 @@ Candidat **chargmentCandid(char *nomFich, int tphys, int *tailleL)
fclose(flot); fclose(flot);
exit(1); exit(1);
} }
fscanf(flot,"%d",&nbCandidat);
*(tcandid[*tailleL]) = lireCandidat(flot); *(tcandid[*tailleL]) = lireCandidat(flot);
while(!feof(flot)) while(!feof(flot))
{ {
fscanf(flot, "%d", &nbIUT);
tcandid[*tailleL]->idCandIUT = ListeCandidvide();
while(i < nbIUT)
{
tcandid[*tailleL]->idCandIUT = traiterCandidIUT(tcandid[*tailleL]->idCandIUT, flot);
fscanf(flot, "%d", &nbDept);
tcandid[*tailleL]->idCandIUT->idCandDept = ListeCandidDeptvide();
while(j < nbDept)
{
tcandid[*tailleL]->idCandIUT->idCandDept = traiterCandidDept(tcandid[*tailleL]->idCandIUT->idCandDept, flot);
j = j + 1;
}
j = 0;
i = i + 1;
}
i = 0;
*tailleL = *tailleL + 1;
tcandid[*tailleL] = (Candidat *)malloc(sizeof(Candidat));
if (tcandid[*tailleL] == NULL)
{
printf("Erreur malloc candidat !\n");
fclose(flot);
exit(1);
} }
*(tcandid[*tailleL]) = lireCandidat(flot);
}
if (tailleL == 0)
printf("Fichier vide !\n");
fclose(flot);
return tcandid;
} }
Candidat lireCandidat(FILE *flot) Candidat lireCandidat(FILE *flot)
{ {
Candidat c; Candidat c;
fscanf(flot,"%a",&c.id); fscanf(flot,"%d",&c.id);
fscanf(flot,"%s",c.nom); fscanf(flot,"%s%*c",c.nom);
fgets(c.prenom,30,flot); fgets(c.prenom,30,flot);
c.prenom[strlen(c.prenom) - 1] = '\0'; c.prenom[strlen(c.prenom) - 1] = '\0';
fscanf(flot,"%d %d %d %d", c.note[0], c.note[1], c.note[2], c.note[3]); fscanf(flot,"%f %f %f %f", &c.note[0], &c.note[1], &c.note[2], &c.note[3]);
printf("%d %s %s %f %f %f %f\n",c.id, c.nom, c.prenom,c.note[0], c.note[1], c.note[2], c.note[3] );
return c; return c;
} }
@ -803,6 +854,7 @@ ListeCandid traiterCandidIUT(ListeCandid l, FILE *flot)
char ville[30]; char ville[30];
fscanf(flot,"%s",ville); fscanf(flot,"%s",ville);
l = insererCandid(l , ville); l = insererCandid(l , ville);
printf("\n %s \n",l->iutCandid);
return l; return l;
} }
@ -810,9 +862,8 @@ ListeCandidDept traiterCandidDept(ListeCandidDept l, FILE *flot)
{ {
char departement[30]; char departement[30];
int deciDept, deciCandid; int deciDept, deciCandid;
fscanf(flot,"%s",departement); fscanf(flot,"%s %d %d",departement, &deciDept, &deciCandid);
fscanf(flot,"%d",deciDept); l = insererCandidDept(l, departement, deciDept, deciCandid);
fscanf(flot,"%d",deciCandid); printf("\n %s %d %d \n", l->departement, l->decisionDept, l->decisionCandid);
l = insererCandidDept(l);
return l; return l;
} }

50
SAE.h

@ -24,20 +24,20 @@ typedef struct
//######################################### //#########################################
//######################################### //#########################################
typedef struct maillonEtuDept typedef struct maillonCandidDept
{ {
char departement[30]; char departement[30];
int decisionDept; int decisionDept;
int decisionCandid; int decisionCandid;
struct maillonEtuDept *suiv; struct maillonCandidDept *suiv;
}MaillonEtuDept, *ListeCandidDept; }MaillonCandidDept, *ListeCandidDept;
typedef struct maillonEtu typedef struct maillonEtu
{ {
char iutCandid[30]; char iutCandid[30];
MaillonEtuDept *idCandDept; MaillonCandidDept *idCandDept;
struct maillonEtu *suiv; struct maillonEtu *suiv;
}MaillonCandid, *ListeCandidIUT; }MaillonCandid, *ListeCandid;
typedef struct typedef struct
@ -45,7 +45,7 @@ typedef struct
int id; int id;
char nom[30]; char nom[30];
char prenom[30]; char prenom[30];
int note[4]; float note[4];
MaillonCandid *idCandIUT; MaillonCandid *idCandIUT;
}Candidat; }Candidat;
@ -126,3 +126,41 @@ int longueurListe(ListeDept l);
void SauvegarderIUT(VilleIUT** tabV, int tailleL); void SauvegarderIUT(VilleIUT** tabV, int tailleL);
void SauvegarderListe(ListeDept l, FILE* flot); void SauvegarderListe(ListeDept l, FILE* flot);
//#######################################################
//#######################################################
//#######################################################
ListeCandid ListeCandidvide(void);
ListeCandidDept ListeCandidDeptvide(void);
ListeCandidDept insererEnTeteCandidDept(ListeCandidDept l, char departement[], int deciDept, int deciCandid);
ListeCandidDept insererCandidDept(ListeCandidDept l, char departement[], int deciDept, int deciCandid);
ListeCandid insererEnTeteCandid(ListeCandid l, char *ville);
ListeCandid insererCandid(ListeCandid l, char *ville);
ListeCandidDept suppressionEnTeteCandidDept(ListeCandidDept l);
ListeCandidDept suppressionCandidDept(ListeCandidDept l, char *departement);
ListeCandid suppressionEnTeteCandid(ListeCandid l);
ListeCandid suppressionCandid(ListeCandid l, char *ville);
void afficherCandidDept(ListeCandidDept l);
void afficherCandid(ListeCandid l);
int longueur(ListeCandid l);
Candidat **chargmentCandid(char *nomFich, int tphys, int *tailleL);
Candidat lireCandidat(FILE *flot);
ListeCandid traiterCandidIUT(ListeCandid l, FILE *flot);
ListeCandidDept traiterCandidDept(ListeCandidDept l, FILE *flot);

@ -0,0 +1,33 @@
4
1
Paul Bocluse
14 9 7 18
2
Clermont-Ferrand
2
Informatique 0 0
Réseaux 0 0
Lyon
1
Jeu-vidéos 0 0
2
Sam Hirrite
17 17 14 11
1
Lyon
1
GEA 0 0
3
Guy Alone
11 9 4 8
1
Clermont-Ferrand
1
Réseaux 0 0
4
Don Qui Roté
14 5 9 12
1
Clermont-Ferrand
1
Informatique 0 0

@ -6,5 +6,3 @@ Lyon
2 2
Jeux-videos 24 Kojima Hideo Jeux-videos 24 Kojima Hideo
GEA 8 Marx Karl GEA 8 Marx Karl

Loading…
Cancel
Save