diff --git a/SAE.c b/SAE.c index 608cb42..70a6b8f 100644 --- a/SAE.c +++ b/SAE.c @@ -199,14 +199,33 @@ int gestionMenuAdmin(VilleIUT **tiut, int nbEle) void global(void) { - int tailleL, i; + /*int tailleL, i; VilleIUT** tab; char nomFich[20]; strcpy(nomFich,"iut.txt"); printf("charg\n"); tab = chargementVille(nomFich,30,&tailleL); 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) @@ -390,7 +409,7 @@ void MiseAJourNbPlace(VilleIUT **tiut, int nbEle) if (aux != NULL) { printf("Ancien nombre de places : %d\n",aux->nbPers); - printf("Nouveau nombre de places : ", nouvNbPlace); + printf("Nouveau nombre de places : "); scanf("%d", &nouvNbPlace); aux->nbPers = nouvNbPlace; printf("Mise à jour effectuer avec succès !"); @@ -460,7 +479,7 @@ void suppressionDept(VilleIUT **tiut, int nbEle) { MaillonDept *aux; char code[30]; - int trouve, pos, nbP; + int trouve, pos; while(1) { printf("Dans quel IUT voulez-vous supprimer un département : "); @@ -493,7 +512,7 @@ void modifChefDept(VilleIUT **tiut, int nbEle) { MaillonDept *aux; char code[30]; - int trouve, pos, nbP; + int trouve, pos; while(1) { printf("Dans quel IUT voulez-vous modifier le chef de département : "); @@ -610,7 +629,7 @@ ListeCandidDept ListeCandidDeptvide(void) return NULL; } -ListeCandidDept insererEnTeteCandidDept(ListeCandidDept l, char departement[], char deciDept[], int deciCandid) +ListeCandidDept insererEnTeteCandidDept(ListeCandidDept l, char departement[], int deciDept, int deciCandid) { MaillonCandidDept *m; m = (MaillonCandidDept *)malloc(sizeof(MaillonCandidDept)); @@ -621,7 +640,7 @@ ListeCandidDept insererEnTeteCandidDept(ListeCandidDept l, char departement[], c } strcpy(m->departement, departement); m->decisionDept = deciDept; - m->deciCandid = deciCandid; + m->decisionCandid = deciCandid; m->suiv = l; return m; } @@ -648,7 +667,7 @@ ListeCandid insererEnTeteCandid(ListeCandid l, char *ville) printf("Pb maillon"); exit(1); } - strcpy(ville, l->iutcandid); + strcpy(m->iutCandid, ville); m->suiv = l; return m; } @@ -657,9 +676,9 @@ ListeCandid insererCandid(ListeCandid l, char *ville) { if (l == NULL) return insererEnTeteCandid(l, ville); - if (strcmp(ville, l->iutcandid) < 0) + if (strcmp(ville, l->iutCandid) < 0) return insererEnTeteCandid(l, ville); - if (strcmp(ville, l->iutcandid) == 0) + if (strcmp(ville, l->iutCandid) == 0) return l; l->suiv = insererCandid(l->suiv, ville); return l; @@ -709,9 +728,10 @@ ListeCandid suppressionCandid(ListeCandid l, char *ville) { if (l == NULL) return l; - if (strcmp(ville, l->iutcandid) < 0) + if (strcmp(ville, l->iutCandid) < 0) return l; - if (strcmp(ville, l->iutcandid) == 0) + if (strcmp(ville, l->iutCandid) == 0) + { while (1) { if (l->idCandDept == NULL) @@ -719,7 +739,8 @@ ListeCandid suppressionCandid(ListeCandid l, char *ville) suppressionEnTeteCandidDept(l->idCandDept); } return suppressionEnTeteCandid(l); - l->suiv = suppressionCandid(l->suiv); + } + l->suiv = suppressionCandid(l->suiv, ville); return l; } @@ -741,7 +762,7 @@ void afficherCandid(ListeCandid l) aux = l; while(aux != NULL) { - printf("%s\t",aux->iutcandid); + printf("%s\t",aux->iutCandid); afficherCandidDept(aux->idCandDept); aux = aux->suiv; } @@ -757,11 +778,11 @@ int longueur(ListeCandid l) Candidat **chargmentCandid(char *nomFich, int tphys, int *tailleL) { - int i = 0, nbCandidat, nbCandid; + int i = 0, j = 0, nbCandidat, nbIUT, nbDept; FILE *flot; Candidat **tcandid; - tcandid = (Candidat *)malloc(sizeof(Candidat) * tphys); - if (tabV == NULL) + tcandid = (Candidat **)malloc(sizeof(Candidat *) * tphys); + if (tcandid == NULL) { printf("Erreur malloc tcandid !\n"); exit(1); @@ -780,21 +801,51 @@ Candidat **chargmentCandid(char *nomFich, int tphys, int *tailleL) fclose(flot); exit(1); } + fscanf(flot,"%d",&nbCandidat); *(tcandid[*tailleL]) = lireCandidat(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 c; - fscanf(flot,"%a",&c.id); - fscanf(flot,"%s",c.nom); + fscanf(flot,"%d",&c.id); + fscanf(flot,"%s%*c",c.nom); fgets(c.prenom,30,flot); 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; } @@ -803,6 +854,7 @@ ListeCandid traiterCandidIUT(ListeCandid l, FILE *flot) char ville[30]; fscanf(flot,"%s",ville); l = insererCandid(l , ville); + printf("\n %s \n",l->iutCandid); return l; } @@ -810,9 +862,8 @@ ListeCandidDept traiterCandidDept(ListeCandidDept l, FILE *flot) { char departement[30]; int deciDept, deciCandid; - fscanf(flot,"%s",departement); - fscanf(flot,"%d",deciDept); - fscanf(flot,"%d",deciCandid); - l = insererCandidDept(l); + fscanf(flot,"%s %d %d",departement, &deciDept, &deciCandid); + l = insererCandidDept(l, departement, deciDept, deciCandid); + printf("\n %s %d %d \n", l->departement, l->decisionDept, l->decisionCandid); return l; -} +} \ No newline at end of file diff --git a/SAE.h b/SAE.h index bb8fea3..4456d03 100644 --- a/SAE.h +++ b/SAE.h @@ -24,20 +24,20 @@ typedef struct //######################################### //######################################### -typedef struct maillonEtuDept +typedef struct maillonCandidDept { char departement[30]; int decisionDept; int decisionCandid; - struct maillonEtuDept *suiv; -}MaillonEtuDept, *ListeCandidDept; + struct maillonCandidDept *suiv; +}MaillonCandidDept, *ListeCandidDept; typedef struct maillonEtu { char iutCandid[30]; - MaillonEtuDept *idCandDept; + MaillonCandidDept *idCandDept; struct maillonEtu *suiv; -}MaillonCandid, *ListeCandidIUT; +}MaillonCandid, *ListeCandid; typedef struct @@ -45,7 +45,7 @@ typedef struct int id; char nom[30]; char prenom[30]; - int note[4]; + float note[4]; MaillonCandid *idCandIUT; }Candidat; @@ -126,3 +126,41 @@ int longueurListe(ListeDept l); void SauvegarderIUT(VilleIUT** tabV, int tailleL); 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); \ No newline at end of file diff --git a/candidature.txt b/candidature.txt new file mode 100644 index 0000000..fe510f3 --- /dev/null +++ b/candidature.txt @@ -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 diff --git a/iut.txt b/iut.txt index bad4ce0..fae1ead 100644 --- a/iut.txt +++ b/iut.txt @@ -6,5 +6,3 @@ Lyon 2 Jeux-videos 24 Kojima Hideo GEA 8 Marx Karl - -