MODIF structure et code Partie 2

master
Matheo THIERRY 2 years ago
parent 35c5f3e2f4
commit baa7169649

@ -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

@ -7,7 +7,7 @@
// f enregistrement // f enregistrement
/*
// Partie 1 // Partie 1
@ -28,7 +28,7 @@ VilleIUT lire(FILE * fe) {
v.Idept->responsable[strlen(v.Idept->responsable)-1] = '\0'; v.Idept->responsable[strlen(v.Idept->responsable)-1] = '\0';
return v; return v;
} }
*/
// Partie 2 // Partie 2
/* /*
@ -72,78 +72,38 @@ charger -- recup :
-nb choix -nb choix
-listcand -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){ Listchoixdept lireChoix(FILE *fe, int nbchoix){
if(f.tete==NULL){return True;}
return False;
}
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("<! pb malloc in enfiler !>");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){
listcandinfo lireMat(FILE *fe){ int i;
listcandinfo etu; listetuinfo b;
fscanf(fe ,"%d", &etu.numetu); 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);
fgets(etu.numetu, 31, fe); *b.lchoixdept = lireChoix(fe, b.nbchoix);
*(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){ int chargeretudiant(char nomFich[], listetuinfo *tetu[]){
listcandinfo a; int i=0, nbetu;
listcand b; listetuinfo a;
int i=0;
FILE *fe; FILE *fe;
fe = fopen( nomFich , "r"); fe = fopen( nomFich, "r");
if(fe==NULL){printf("<! pb in chargeFmatieres to open file !>\n");return-1;} if(fe==NULL){printf("<! pb ouverture fichier in chargeretudiant !>\n");return-1;}
a = lireMat(fe); fscanf(fe, "%d", &nbetu);
while(!feof(fe)){ while(!feof(fe)){
if(i==Tmax){printf("<! pb in chargeFmatieres with tMat capacity !>\n");fclose(fe);return-1;} a = lireEtu(fe);
tinfoetu[i] = (listcandinfo*)malloc(sizeof(listcandinfo)); tetu[i] = (listetuinfo*)malloc(sizeof(listetuinfo));
if(table[i]==NULL){printf("<! pb in chargeFmatieres with tMat malloc !>\n");fclose(fe);return-1;} if(tetu[i]==NULL){printf("<! pb malloc in chargeretudiant !>\n");fclose(fe);return-1;}
*tinfoetu[i]= a; *tetu[i] = a;
a = lireMat(fe);
i++; i++;
} }
fclose(fe);
return i;
} }
void test1(void){
}
@ -153,7 +113,7 @@ int chargetableaux(char nomFich[], listcandinfo *tinfoetu[], listcanddept *tcart
// Partie 4 // Partie 4
// Général (menu et ce qui en ai relié) // Général (menu et ce qui en ai relié)
/*
questionadmin(){ questionadmin(){
printf("\nQuel numéro détudiant ?\n==>"); printf("\nQuel numéro détudiant ?\n==>");
scanf("%d%*c", &choix); scanf("%d%*c", &choix);
@ -190,3 +150,4 @@ int menu(void){
return 1; return 1;
} }
*/

@ -27,28 +27,22 @@ typedef struct VilleIUT{
// Partie 2 // Partie 2
typedef struct{ typedef struct listchoix{
int numetu;
char nometu[31];
char prenometu[31];
int notes[4];
int nbchoix;
}listcandinfo;
typedef struct listcand{
char Ville[31]; char Ville[31];
char dep[31]; char dep[31];
int decision; int decision;
int validation; int validation;
struct listcand* suivant; struct listchoix* suivant;
}Mailloncartecand, listcanddept; }Maillonchoix, *Listchoixdept;
typedef struct{ typedef struct{
Mailloncartecand* tete; int numeroetu;
Mailloncartecand* queue; char nometu[21];
}Filecartecand; char prenometu[21];
int notes[4];
typedef enum {False,True}booleen; int nbchoix;
Listchoixdept* lchoixdept;
}listetuinfo;
// Partie 3 // Partie 3
typedef struct listresp{ typedef struct listresp{
@ -66,3 +60,4 @@ typedef struct listatt{
struct listatt* suivant; struct listatt* suivant;
}maillonatt; }maillonatt;
void test1(void);
Loading…
Cancel
Save