From baa7169649dd1766a6ba48665a4499f29d802546 Mon Sep 17 00:00:00 2001 From: "matheo.thierry" Date: Fri, 16 Dec 2022 14:34:59 +0100 Subject: [PATCH] MODIF structure et code Partie 2 --- candidature.txt | 205 ++++++++++++++++++++++++++++++++++++++++++++++++ sae1-02.c | 87 ++++++-------------- sae1-02.h | 27 +++---- 3 files changed, 240 insertions(+), 79 deletions(-) create mode 100644 candidature.txt diff --git a/candidature.txt b/candidature.txt new file mode 100644 index 0000000..05e5df8 --- /dev/null +++ b/candidature.txt @@ -0,0 +1,205 @@ +12 +1 +cheval +blanc +10 12 13 16 +3 +clermont-ferrand +informatique +0 +0 +grenoble +informatique +0 +0 +aurillac +bio-informatique +0 +0 +2 +fou +blanc +10 12 13 16 +3 +clermont-ferrand +informatique +0 +0 +grenoble +informatique +0 +0 +aurillac +bio-informatique +0 +0 +3 +roi +blanc +10 12 13 16 +3 +clermont-ferrand +informatique +0 +0 +grenoble +informatique +0 +0 +aurillac +bio-informatique +0 +0 +4 +reine +blanc +10 12 13 16 +3 +clermont-ferrand +informatique +0 +0 +grenoble +informatique +0 +0 +aurillac +bio-informatique +0 +0 +5 +tour +blanc +10 12 13 16 +3 +clermont-ferrand +informatique +0 +0 +grenoble +informatique +0 +0 +aurillac +bio-informatique +0 +0 +6 +pion +blanc +10 12 13 16 +3 +clermont-ferrand +informatique +0 +0 +grenoble +informatique +0 +0 +aurillac +bio-informatique +0 +0 +7 +cheval +noir +10 12 13 16 +3 +clermont-ferrand +informatique +0 +0 +grenoble +informatique +0 +0 +aurillac +bio-informatique +0 +0 +8 +fou +noir +10 12 13 16 +3 +clermont-ferrand +informatique +0 +0 +grenoble +informatique +0 +0 +aurillac +bio-informatique +0 +0 +9 +roi +noir +10 12 13 16 +3 +clermont-ferrand +informatique +0 +0 +grenoble +informatique +0 +0 +aurillac +bio-informatique +0 +0 +10 +reine +noir +10 12 13 16 +3 +clermont-ferrand +informatique +0 +0 +grenoble +informatique +0 +0 +aurillac +bio-informatique +0 +0 +11 +tour +noir +10 12 13 16 +3 +clermont-ferrand +informatique +0 +0 +grenoble +informatique +0 +0 +aurillac +bio-informatique +0 +0 +12 +pion +noir +10 12 13 16 +3 +clermont-ferrand +informatique +0 +0 +grenoble +informatique +0 +0 +aurillac +bio-informatique +0 +0 diff --git a/sae1-02.c b/sae1-02.c index 1bf7790..7ca6284 100644 --- a/sae1-02.c +++ b/sae1-02.c @@ -7,7 +7,7 @@ // f enregistrement - +/* // Partie 1 @@ -28,7 +28,7 @@ VilleIUT lire(FILE * fe) { v.Idept->responsable[strlen(v.Idept->responsable)-1] = '\0'; return v; } - +*/ // Partie 2 /* @@ -72,78 +72,38 @@ charger -- recup : -nb choix -listcand -j'ai deux tableau 1 avec infoetu et l'autre les choix de l'etu au meme niveau que lui -tinfoetu est tableau de pointeur sur structure -tcarteetu est tableau de pointeur sur files - - -quand on quitte il vide tout avec free */ -booleen listevide(Filecartecand f){ - if(f.tete==NULL){return True;} - return False; -} +Listchoixdept lireChoix(FILE *fe, int nbchoix){ -Filecartecand initial(void){ - Filecartecand f; f.queue=NULL; f.tete=NULL; return f; -} +} -Filecartecand enfiler(Filecartecand f, char Ville[], char dep[], int decision, int validation){ - Mailloncartecand*m; - m=(Mailloncartecand*)malloc(sizeof(Mailloncartecand*)); - if(m==NULL){printf("");exit(1);} - strcpy(m->Ville,Ville); - strcpy(m->dep,dep); - m->decision=decision; - m->validation=validation; - m->suivant=NULL; - if(listevide(f)){ - f.tete=m; - f.queue=m; - }else{ - f.queue->suivant=m; - f.queue=m; - } - return f; +listetuinfo lireEtu(FILE *fe){ + int i; + listetuinfo b; + fscanf(fe, "%d %s %s %d %d %d %d %d", &b.numeroetu, b.nometu, b.prenometu, &b.notes[0], &b.notes[1], &b.notes[2], &b.notes[3], &b.nbchoix); + *b.lchoixdept = lireChoix(fe, b.nbchoix); } - -listcandinfo lireMat(FILE *fe){ - listcandinfo etu; - fscanf(fe ,"%d", &etu.numetu); - fgets(etu.numetu, 31, fe); - *(etu.numetu +(strlen(etu.numetu) - 1)) = '\0'; - fgets(etu.prenometu, 31, fe); - *(etu.prenometu +(strlen(etu.prenometu) - 1)) = '\0'; - fscanf(fe ,"%d %d %d %d %d", &etu.note[1], &etu.note[2], &etu.note[3], &etu.[4], &etu.choix); - return etu; -} - -int chargetableaux(char nomFich[], listcandinfo *tinfoetu[], listcanddept *tcarteetu[], int Tmax){ - listcandinfo a; - listcand b; - int i=0; +int chargeretudiant(char nomFich[], listetuinfo *tetu[]){ + int i=0, nbetu; + listetuinfo a; FILE *fe; - fe = fopen( nomFich , "r"); - if(fe==NULL){printf("\n");return-1;} - a = lireMat(fe); + fe = fopen( nomFich, "r"); + if(fe==NULL){printf("\n");return-1;} + fscanf(fe, "%d", &nbetu); while(!feof(fe)){ - if(i==Tmax){printf("\n");fclose(fe);return-1;} - tinfoetu[i] = (listcandinfo*)malloc(sizeof(listcandinfo)); - if(table[i]==NULL){printf("\n");fclose(fe);return-1;} - *tinfoetu[i]= a; - a = lireMat(fe); + a = lireEtu(fe); + tetu[i] = (listetuinfo*)malloc(sizeof(listetuinfo)); + if(tetu[i]==NULL){printf("\n");fclose(fe);return-1;} + *tetu[i] = a; i++; } - fclose(fe); - return i; -} - - - +} +void test1(void){ +} @@ -153,7 +113,7 @@ int chargetableaux(char nomFich[], listcandinfo *tinfoetu[], listcanddept *tcart // Partie 4 // Général (menu et ce qui en ai relié) - +/* questionadmin(){ printf("\nQuel numéro détudiant ?\n==>"); scanf("%d%*c", &choix); @@ -190,3 +150,4 @@ int menu(void){ return 1; } +*/ \ No newline at end of file diff --git a/sae1-02.h b/sae1-02.h index 4ca13a6..e2840c7 100644 --- a/sae1-02.h +++ b/sae1-02.h @@ -27,28 +27,22 @@ typedef struct VilleIUT{ // Partie 2 -typedef struct{ - int numetu; - char nometu[31]; - char prenometu[31]; - int notes[4]; - int nbchoix; -}listcandinfo; - -typedef struct listcand{ +typedef struct listchoix{ char Ville[31]; char dep[31]; int decision; int validation; - struct listcand* suivant; -}Mailloncartecand, listcanddept; + struct listchoix* suivant; +}Maillonchoix, *Listchoixdept; typedef struct{ - Mailloncartecand* tete; - Mailloncartecand* queue; -}Filecartecand; - -typedef enum {False,True}booleen; + int numeroetu; + char nometu[21]; + char prenometu[21]; + int notes[4]; + int nbchoix; + Listchoixdept* lchoixdept; +}listetuinfo; // Partie 3 typedef struct listresp{ @@ -66,3 +60,4 @@ typedef struct listatt{ struct listatt* suivant; }maillonatt; +void test1(void); \ No newline at end of file