From 1d12c200762c2b774f311002ebf7513258863eea Mon Sep 17 00:00:00 2001 From: Alexis LAURENT Date: Wed, 11 Jan 2023 17:30:29 +0100 Subject: [PATCH] Chargement Candid marche --- SAE.c | 95 +++++++++++++++++++++++++++---------------------- SAE.h | 8 +++-- candidature.txt | 2 +- 3 files changed, 59 insertions(+), 46 deletions(-) diff --git a/SAE.c b/SAE.c index 236e882..a86a8f2 100644 --- a/SAE.c +++ b/SAE.c @@ -1,4 +1,5 @@ #include "SAE.h" +//#include "SAEl.h" bool motdepasseVerif(void) { @@ -206,11 +207,14 @@ void global(void) printf("charg\n"); tab = chargementVille(nomFich,30,&tailleL); printf("\n"); - gestionMenu(tab, tailleL);*/ + gestionMenu(tab, tailleL); + SauvegardeIUT(tab, tailleL) + */ int tphys, nb; Candidat **tab; tab = chargmentCandid("candidature.txt", &tphys, &nb); - afficherCandid(tab[0]->idCandIUT); + system("clear"); + afficherCandid(tab, nb); } @@ -653,29 +657,6 @@ void triEchangeCandidDept(ChoixDept **tDept, int tailleL) } } -ChoixDept ** insererTDept(ChoixDept **tDept, int tailleP, int tailleL ,char dept[], int deciDept, int deciCandid) -{ - ChoixDept **aux; - aux = tDept; - int trouve, pos; - printf("1"); - if (tailleL == tailleP) - { - aux = (ChoixDept **)realloc(tDept, (tailleP + 1) * sizeof(ChoixDept *)); - if (aux == NULL) - { - printf("pb réalloc\n"); - exit(1); - } - } - printf("2"); - strcpy(aux[tailleL]->departement, dept); - aux[tailleL]->decisionDept = deciDept; - aux[tailleL]->decisionCandid = deciCandid; - printf("%s %d %d", aux[tailleL]->departement, aux[tailleL]->decisionDept, aux[tailleL]->decisionCandid); - return aux; -} - void videTabDept(ChoixDept **tDept, int tailleP) { ChoixDept *aux; @@ -714,21 +695,35 @@ ListeCandid suppressionCandid(ListeCandid l, char *ville, ChoixDept **tDept, int return l; } -void afficherCandid(ListeCandid l) +void afficherCandid(Candidat **tab, int nbEle) { - MaillonCandid *aux; int i; - aux = l; - while(aux != NULL) + for (i=0; i < nbEle; i++) { - printf("%s\t",aux->iutCandid); - for (i = 0; i < aux->nbChoix;i++) - printf("%s %d %d\n", aux->tabDept[i]->departement, aux->tabDept[i]->decisionDept, aux->tabDept[i]->decisionCandid); - aux = aux->suiv; + printf("%d %s %s |%.1f %.1f %.1f %.1f|\n", tab[i]->id, tab[i]->nom, tab[i]->prenom, tab[i]->note[0], tab[i]->note[1], tab[i]->note[2], tab[i]->note[3]); + afficherCandidIUT(tab[i]->idCandIUT); } printf("\n"); } +void afficherCandidIUT(ListeCandid l) +{ + if (l == NULL) + return; + printf("%s : %d\n", l->iutCandid,l->nbChoix); + afficherCandidDept(l->tabDept, l->nbChoix); + l=l->suiv; + return afficherCandidIUT(l); +} + +void afficherCandidDept(ChoixDept **tab, int nbChoix) +{ + int i; + for (i=0; i < nbChoix; i++) + { + printf("|%s %d %d|", tab[i]->departement, tab[i]->decisionDept, tab[i]->decisionCandid); + } +} int longueur(ListeCandid l) { if(l==NULL) @@ -738,10 +733,9 @@ int longueur(ListeCandid l) Candidat **chargmentCandid(char *nomFich, int *tphys, int *tailleL) { - int i = 0, nbIUT, nbDept; + int i = 0, j = 0, nbIUT, nbDept; FILE *flot; Candidat **tcandid; - ChoixDept **tDept; flot = fopen(nomFich, "r"); if (flot == NULL) { @@ -784,6 +778,7 @@ Candidat **chargmentCandid(char *nomFich, int *tphys, int *tailleL) fclose(flot); exit(1); } + printf("\n\n"); *(tcandid[*tailleL]) = lireCandidat(flot); } if (tailleL == 0) @@ -813,7 +808,7 @@ ListeCandid traiterCandidIUT(ListeCandid l, FILE *flot) fscanf(flot, "%d", &nbDept); printf("%s |%d|\n", ville, nbDept); - tDept = (ChoixDept **)malloc(sizeof(ChoixDept *)*nbDept); + tDept = (ChoixDept **)malloc(sizeof(ChoixDept *)*(nbDept + 5)); if(tDept == NULL) { printf("Pb malloc candidIUt\n"); @@ -821,23 +816,37 @@ ListeCandid traiterCandidIUT(ListeCandid l, FILE *flot) } while (i < nbDept) { - tDept = traiterCandidDept(tDept, i, nbDept, flot); + tDept[i] = traiterCandidDept(i, nbDept, flot); i = i + 1; } l = insererCandid(l , ville , tDept, nbDept); return l; } -ChoixDept **traiterCandidDept(ChoixDept **tDept,int tailleL, int tailleP, FILE *flot) +ChoixDept *traiterCandidDept(int tailleL, int tailleP, FILE *flot) { + ChoixDept *cD; char dept[30]; int deciDept, deciCandid; + cD = (ChoixDept *)malloc(sizeof(ChoixDept)); + if (cD == NULL) + { + printf("Pb malloc"); + exit(1); + } fscanf(flot,"%s", dept); fscanf(flot,"%d", &deciDept); fscanf(flot,"%d",&deciCandid); - printf("|%s %d %d|\n", dept, deciDept, deciCandid); - printf("a"); - tDept = insererTDept(tDept, tailleP, tailleL , dept, deciDept, deciCandid); - printf("1"); - return tDept; + strcpy(cD->departement, dept); + cD->decisionDept = deciDept; + cD->decisionCandid = deciCandid; + printf("|%s %d %d|\n", cD->departement, cD->decisionDept, cD->decisionCandid); + return cD; +} + +void supprimerCandid(Candidat **tab, int *nbEle) +{ + int idSup; + printf("Identifiant de la candidiature à supprimer : "); + scan } \ No newline at end of file diff --git a/SAE.h b/SAE.h index 98bbcba..5d80234 100644 --- a/SAE.h +++ b/SAE.h @@ -152,7 +152,11 @@ ListeCandid suppressionEnTeteCandid(ListeCandid l , ChoixDept **tDept, int taill ListeCandid suppressionCandid(ListeCandid l, char *ville, ChoixDept **tDept, int tailleP); -void afficherCandid(ListeCandid l); +void afficherCandid(Candidat **tab, int nbEle); + +void afficherCandidIUT(ListeCandid l); + +void afficherCandidDept(ChoixDept **tab, int nbChoix); int longueur(ListeCandid l); @@ -162,4 +166,4 @@ Candidat lireCandidat(FILE *flot); ListeCandid traiterCandidIUT(ListeCandid l, FILE *flot); -ChoixDept **traiterCandidDept(ChoixDept **tDept,int tailleL, int tailleP, FILE *flot); \ No newline at end of file +ChoixDept *traiterCandidDept(int tailleL, int tailleP, FILE *flot); \ No newline at end of file diff --git a/candidature.txt b/candidature.txt index 739a15b..f943b4a 100644 --- a/candidature.txt +++ b/candidature.txt @@ -50,4 +50,4 @@ Informatique 0 Réseaux 0 -0 \ No newline at end of file +0