|
|
|
@ -365,7 +365,7 @@ void test(void){
|
|
|
|
|
// Partie 2
|
|
|
|
|
|
|
|
|
|
//chargement ======================================================================================================================================================================
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
Listchoixdept listvide(void){return NULL;}
|
|
|
|
|
|
|
|
|
|
Listchoixdept lireCarte(FILE *fe, int nbchoix){
|
|
|
|
@ -406,6 +406,22 @@ int chargeretudiant(char nomFich[], listetuinfo *tetu[], int tmax){
|
|
|
|
|
return nbetu;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//rechercher etu ==============================================================================================================================================================
|
|
|
|
|
|
|
|
|
|
int recherdicoetu(listetuinfo *tetu[], int nb, int num){
|
|
|
|
|
int d=0, m, f=nb-1;
|
|
|
|
|
while(d<=f){
|
|
|
|
|
m=(d+f)/2;
|
|
|
|
|
if(tetu[m]->numeroetu==num){return m;}
|
|
|
|
|
if(tetu[m]->numeroetu<num){
|
|
|
|
|
f=m-1;
|
|
|
|
|
}else{
|
|
|
|
|
d=m+1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//enregistrement ========================================================================================================================================================
|
|
|
|
|
|
|
|
|
|
void enregistrementcarte(FILE *fe, Maillonchoix* carte, int nb){
|
|
|
|
@ -415,18 +431,18 @@ void enregistrementcarte(FILE *fe, Maillonchoix* carte, int nb){
|
|
|
|
|
free(carte);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void enregistrementinfo(FILE *fe, listetuinfo etu){
|
|
|
|
|
void enregistrementinfo(FILE *fe, listetuinfo *etu){
|
|
|
|
|
Listchoixdept b;
|
|
|
|
|
int i=0;
|
|
|
|
|
b = etu.carte;
|
|
|
|
|
fprintf(fe, "%d\n%s\n%s\n%d %d %d %d\n%d\n", etu.numeroetu, etu.nometu, etu.prenometu, etu.notes, etu.nbchoix);
|
|
|
|
|
enregistrementcarte(fe, b, etu.nbchoix);
|
|
|
|
|
b = etu->carte;
|
|
|
|
|
fprintf(fe, "%d\n%s\n%s\n%d %d %d %d\n%d\n", etu->numeroetu, etu->nometu, etu->prenometu, etu->notes, etu->nbchoix);
|
|
|
|
|
enregistrementcarte(fe, b, etu->nbchoix);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int enregistrementetudiants(char nomFich[], listetuinfo *tetu[], int nb){
|
|
|
|
|
int i=0;
|
|
|
|
|
FILE *fe;
|
|
|
|
|
listetuinfo etu;
|
|
|
|
|
listetuinfo *etu;
|
|
|
|
|
fe = fopen( nomFich, "w");
|
|
|
|
|
if(fe==NULL){printf("<! pb fichier in enregistrementetudiant !>\n");return-1;}
|
|
|
|
|
fprintf(fe, "%d\n", nb);
|
|
|
|
@ -438,40 +454,45 @@ int enregistrementetudiants(char nomFich[], listetuinfo *tetu[], int nb){
|
|
|
|
|
fclose(fe);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//=============================================================================================================================================================================================================================
|
|
|
|
|
|
|
|
|
|
//général fonction for ajouter modifier et supprimer ========================================================================================
|
|
|
|
|
//affichage =======================================================================================================================================================
|
|
|
|
|
|
|
|
|
|
void affichagedep(MaillonDept* carte){
|
|
|
|
|
if(carte==NULL){return;}
|
|
|
|
|
printf("%s", carte->departement);
|
|
|
|
|
affichagedep(carte->suivant);
|
|
|
|
|
//affiche que les cartes d'une personne
|
|
|
|
|
void affichagecarte(Listchoixdept c){
|
|
|
|
|
if(c==NULL){printf("\n");return;}
|
|
|
|
|
printf("%s - %s\n \tdécision : %d\n \tvalidation : %d", c->Ville, c->dep, c->decision, c->validation);
|
|
|
|
|
if(c->suivant==NULL){affichagecarte(c->suivant);}
|
|
|
|
|
else{
|
|
|
|
|
printf("\n - ");
|
|
|
|
|
affichagecarte(c->suivant);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void affichagecarte(Maillonchoix* carte){
|
|
|
|
|
if(carte==NULL){return;}
|
|
|
|
|
printf("%s - %s\n", carte->Ville, carte->dep);
|
|
|
|
|
afficherchoix(carte->suivant);
|
|
|
|
|
//affiche que la personne
|
|
|
|
|
void affichageetu(listetuinfo a){
|
|
|
|
|
printf(" %d\n %s %s\n", a.numeroetu, a.nometu, a.prenometu);
|
|
|
|
|
printf(" mathématique : %d -", a.notes[0]);
|
|
|
|
|
printf(" français : %d -", a.notes[1]);
|
|
|
|
|
printf(" anglais : %d -", a.notes[2]);
|
|
|
|
|
printf(" matière spé : %d\n", a.notes[3]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void affichageville(Maillon *tville[], int nbville){
|
|
|
|
|
int i;
|
|
|
|
|
Listdept b;
|
|
|
|
|
for(i=0; i<nbville; i++){
|
|
|
|
|
b = tville[i]->ldept;
|
|
|
|
|
printf("%s :\n", tville[i]->Ville);
|
|
|
|
|
affichagedep(b);
|
|
|
|
|
printf("\n");
|
|
|
|
|
//affichage general
|
|
|
|
|
void affichealletu(listetuinfo *tetu[], int nb){
|
|
|
|
|
int j=0;
|
|
|
|
|
Listchoixdept b;
|
|
|
|
|
b = listvide();
|
|
|
|
|
for(j=0; j<nb; j++){
|
|
|
|
|
affichageetu(*tetu[j]);
|
|
|
|
|
printf("tout les choix :\n - ");
|
|
|
|
|
b = tetu[j]->carte;
|
|
|
|
|
affichagecarte(b);
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void affichervillechoix(Maillon villechoix){
|
|
|
|
|
int i;
|
|
|
|
|
Listdept ldep;
|
|
|
|
|
ldep = villechoix.ldept;
|
|
|
|
|
printf("%s :\n", villechoix.Ville);
|
|
|
|
|
affichagedep(ldep);
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
//général fonction for ajouter modifier et supprimer ========================================================================================
|
|
|
|
|
|
|
|
|
|
int cherchelistcorrespond(MaillonDept* dep, char choixdep[]){
|
|
|
|
|
if(dep==NULL){return -1;}
|
|
|
|
@ -479,12 +500,13 @@ int cherchelistcorrespond(MaillonDept* dep, char choixdep[]){
|
|
|
|
|
return cherchelistcorrespond(dep->suivant, choixdep);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int correspondville(char choixville[], char choixdep[], Maillon *tville[], int nbville){
|
|
|
|
|
|
|
|
|
|
int correspondville(char choixville[], char choixdep[], VilleIUT *tville[], int nbville){
|
|
|
|
|
int i, ok;
|
|
|
|
|
Listdept b;
|
|
|
|
|
for(i=0; i<nbville; i++){
|
|
|
|
|
if(strcmp(tville[i]->Ville,choixville)==0){
|
|
|
|
|
b = tville[i].ldept;
|
|
|
|
|
b = tville[i]->ldept;
|
|
|
|
|
ok = cherchelistcorrespond(b, choixdep);
|
|
|
|
|
if(ok==1){return 1;}
|
|
|
|
|
}
|
|
|
|
@ -492,7 +514,7 @@ int correspondville(char choixville[], char choixdep[], Maillon *tville[], int n
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int correspondcarte(char choixville[], char choixdep[], Maillonchoix* carte){
|
|
|
|
|
int correspondcarte(char choixville[], char choixdep[], Listchoixdept carte){
|
|
|
|
|
if(carte==NULL){return 0;}
|
|
|
|
|
if(strcmp(choixville,carte->Ville)==0){
|
|
|
|
|
if(strcmp(choixdep,carte->dep)==0){
|
|
|
|
@ -502,9 +524,11 @@ int correspondcarte(char choixville[], char choixdep[], Maillonchoix* carte){
|
|
|
|
|
correspondcarte(choixville, choixdep, carte->suivant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ajouter =============================================================================================================================================
|
|
|
|
|
|
|
|
|
|
void choix(Maillon *tville[], int nbville, char choixville[], char choixdep[]){
|
|
|
|
|
void choix(VilleIUT *tville[], int nbville, char choixville[], char choixdep[]){
|
|
|
|
|
int i, ok;
|
|
|
|
|
printf("ville : \n");
|
|
|
|
|
fgets(choixville, 31, stdin);
|
|
|
|
@ -536,7 +560,7 @@ Listchoixdept ajoutercarte(Maillonchoix* a, char choixville[], char choixdep[]){
|
|
|
|
|
return carte;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int allajoutprocess(Maillon *tville[], listetuinfo etu, int nbville){
|
|
|
|
|
void allajoutprocess(VilleIUT *tville[], listetuinfo etu, int nbville){
|
|
|
|
|
int i, ok;
|
|
|
|
|
Listchoixdept b;
|
|
|
|
|
b = etu.carte;
|
|
|
|
@ -546,7 +570,7 @@ int allajoutprocess(Maillon *tville[], listetuinfo etu, int nbville){
|
|
|
|
|
ok = correspondcarte(choixville, choixdep, b);
|
|
|
|
|
if(ok==0){b = ajoutercarte(b, choixville, choixdep);}
|
|
|
|
|
else{printf("\t< choix deja existant >\n");}
|
|
|
|
|
}
|
|
|
|
|
}// possible de devoir rerajouter b dans etu ??????????? et return nb+1
|
|
|
|
|
|
|
|
|
|
//modifier ==============================================================================================================================================================
|
|
|
|
|
|
|
|
|
@ -570,42 +594,56 @@ void choix2(Listchoixdept lcarte, char choixville[], char choixdep[]){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fchoixdep(char choixville[], char choixdep[], Maillon *tville[], int nbville){
|
|
|
|
|
void fchoixdep(char choixville[], char choixdep[], VilleIUT *tville[], int nbville){
|
|
|
|
|
int ok;
|
|
|
|
|
printf("\n< quel departement voulez vous choisir ? >\n==>");
|
|
|
|
|
fgets(choixdep, 31, stdin);
|
|
|
|
|
choixdep[strlen(choixdep)-1]='\0';
|
|
|
|
|
ok = correspondville(choixville, choixdep, tville[i], nbville);
|
|
|
|
|
ok = correspondville(choixville, choixdep, tville, nbville);
|
|
|
|
|
while(ok!=1){
|
|
|
|
|
printf("\n< quel departement voulez vous choisir ? >\n==>");
|
|
|
|
|
fgets(choixdep, 31, stdin);
|
|
|
|
|
choixdep[strlen(choixdep)-1]='\0';
|
|
|
|
|
ok = correspondville(choixville, choixdep, tville[i], nbville);
|
|
|
|
|
ok = correspondville(choixville, choixdep, tville, nbville);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Maillonchoix choixmodifcarte(Maillonchoix dep, char choixville[], char choixdep[]){
|
|
|
|
|
Maillonchoix dep;
|
|
|
|
|
Listchoixdept choixmodifcarte(Listchoixdept dep, char choixville[], char choixdep[], VilleIUT *tville[], int nbville){
|
|
|
|
|
if(dep==NULL){exit(1);}
|
|
|
|
|
if(strcmp(dep->Ville,choixville)==0){
|
|
|
|
|
if(strcmp(dep->dep,choixdep)==0){
|
|
|
|
|
fchoixdep(choixville, choixdep, tville, nbville);
|
|
|
|
|
dep->dep=choixville;
|
|
|
|
|
strcpy(dep->dep,choixdep);
|
|
|
|
|
return dep;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dep->suivant = choixmodifcarte(dep.suivant, choixville, choixdep);
|
|
|
|
|
dep->suivant = choixmodifcarte(dep->suivant, choixville, choixdep, tville, nbville);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int correspondvilleonly(char choixville[], Maillon ville){
|
|
|
|
|
void affichagedep(MaillonDept* carte){
|
|
|
|
|
if(carte==NULL){return;}
|
|
|
|
|
printf("%s", carte->departement);
|
|
|
|
|
affichagedep(carte->suivant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void affichervillechoix(VilleIUT *villechoix){
|
|
|
|
|
int i;
|
|
|
|
|
Listdept ldep;
|
|
|
|
|
ldep = villechoix->ldept;
|
|
|
|
|
printf("%s :\n", villechoix->Ville);
|
|
|
|
|
affichagedep(ldep);
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int correspondvilleonly(char choixville[], VilleIUT *ville){
|
|
|
|
|
Listdept b;
|
|
|
|
|
if(strcmp(ville.Ville,choixville)==0){
|
|
|
|
|
if(strcmp(ville->Ville,choixville)==0){
|
|
|
|
|
affichervillechoix(ville);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void modificationcarte(listetuinfo etu, Maillon *tville[], int nbville){
|
|
|
|
|
void modificationcarte(listetuinfo etu, VilleIUT *tville[], int nbville){
|
|
|
|
|
int i, ok;
|
|
|
|
|
char choixville[31], choixdep[31];
|
|
|
|
|
Listchoixdept lcarte;
|
|
|
|
@ -616,7 +654,7 @@ void modificationcarte(listetuinfo etu, Maillon *tville[], int nbville){
|
|
|
|
|
ok = correspondvilleonly(choixville, tville[i]);
|
|
|
|
|
if(ok==1){
|
|
|
|
|
fchoixdep(choixville, choixdep, tville, nbville);
|
|
|
|
|
lcarte = choixmodifcarte(choixville, choixdep, tville, nbville);
|
|
|
|
|
lcarte = choixmodifcarte(lcarte, choixville, choixdep, tville, nbville);
|
|
|
|
|
etu.carte=lcarte;
|
|
|
|
|
}
|
|
|
|
|
else{printf("\t< choix deja existant >\n");}
|
|
|
|
@ -625,85 +663,33 @@ void modificationcarte(listetuinfo etu, Maillon *tville[], int nbville){
|
|
|
|
|
|
|
|
|
|
//supprimer ==========================================================================================================================================
|
|
|
|
|
|
|
|
|
|
Maillonchoix suppressioncartechoix(char choixville[], char choixdep[], Maillonchoix* carte){
|
|
|
|
|
Maillonchoix* premier, tmp;
|
|
|
|
|
Maillonchoix* suppressioncartechoix(char choixville[], char choixdep[], Listchoixdept carte){
|
|
|
|
|
Maillonchoix *premier, *tmp;
|
|
|
|
|
if(carte==NULL){exit(1);}
|
|
|
|
|
if(strcmp(carte.Ville,choixville)==0){
|
|
|
|
|
if(strcmp(choixdep,carte.dep)==0){
|
|
|
|
|
tmp=carte.suivant;
|
|
|
|
|
if(strcmp(carte->Ville,choixville)==0){
|
|
|
|
|
if(strcmp(choixdep,carte->dep)==0){
|
|
|
|
|
tmp=carte->suivant;
|
|
|
|
|
free(carte);
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
carte = suppressioncartechoix(choixville, choixdep, carte.suivant);
|
|
|
|
|
carte = suppressioncartechoix(choixville, choixdep, carte->suivant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void suppcarte(listetuinfo etu){
|
|
|
|
|
void suppcarte(listetuinfo *etu){
|
|
|
|
|
int i, ok;
|
|
|
|
|
char choixville[31], choixdep[31];
|
|
|
|
|
Listchoixdept lcarte;
|
|
|
|
|
lcarte=etu.carte;
|
|
|
|
|
lcarte = etu->carte;
|
|
|
|
|
affichagecarte(lcarte);
|
|
|
|
|
choix2(lcarte, choixville, choixdep);
|
|
|
|
|
lcarte = suppressioncartechoix(choixville, choixdep, lcarte);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//affichage =======================================================================================================================================================
|
|
|
|
|
|
|
|
|
|
void affichagecarteall(Maillonchoix* carte){
|
|
|
|
|
if(carte==NULL){return;}
|
|
|
|
|
printf("%s - %s\n décision : %d\nvalidation : %d\n", carte->Ville, carte->dep, carte->decision, carte->validation);
|
|
|
|
|
afficherchoix(carte->suivant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void affichageetu(listetuinfo etu){
|
|
|
|
|
Listchoixdept lcarte;
|
|
|
|
|
lcarte=etu.carte;
|
|
|
|
|
printf(" %d\n %s %s\n", a.numeroetu, a.nometu, a.prenometu);
|
|
|
|
|
printf(" mathématique : %d\n", a.notes[0]);
|
|
|
|
|
printf(" français : %d\n", a.notes[1]);
|
|
|
|
|
printf(" anglais : %d\n", a.notes[2]);
|
|
|
|
|
printf(" matière spé : %d\n", a.notes[3]);
|
|
|
|
|
affichagecarteall(lcarte);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void affichage(Listchoixdept c){
|
|
|
|
|
if(c==NULL){printf("\n");return;}
|
|
|
|
|
printf("%s %s %d %d", c->Ville, c->dep, c->decision, c->validation);
|
|
|
|
|
if(c->suivant==NULL){affichage(c->suivant);}
|
|
|
|
|
else{
|
|
|
|
|
printf("\n - ");
|
|
|
|
|
affichage(c->suivant);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//affiche que la personne
|
|
|
|
|
void affichageetu(listetuinfo a){
|
|
|
|
|
printf(" %d\n %s %s\n", a.numeroetu, a.nometu, a.prenometu);
|
|
|
|
|
printf(" mathématique : %d -", a.notes[0]);
|
|
|
|
|
printf(" français : %d -", a.notes[1]);
|
|
|
|
|
printf(" anglais : %d -", a.notes[2]);
|
|
|
|
|
printf(" matière spé : %d\n", a.notes[3]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//affichage general
|
|
|
|
|
void affichealletu(listetuinfo *tetu[], int nb){
|
|
|
|
|
int j=0;
|
|
|
|
|
Listchoixdept b;
|
|
|
|
|
b = listvide();
|
|
|
|
|
for(j=0; j<nb; j++){
|
|
|
|
|
affichageetu(*tetu[j]);
|
|
|
|
|
printf("tout les choix :\n - ");
|
|
|
|
|
b = tetu[j]->carte;
|
|
|
|
|
affichage(b);
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}// return nb -1
|
|
|
|
|
|
|
|
|
|
//=========================================================================================================================================================
|
|
|
|
|
|
|
|
|
|
// zone de test =========================================================================================
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
void test1(void){
|
|
|
|
|
listetuinfo *tetu[5000];
|
|
|
|
|
int nb;
|
|
|
|
@ -712,7 +698,7 @@ void test1(void){
|
|
|
|
|
nb = chargeretudiant(nomFich, tetu, 5000);
|
|
|
|
|
affichealletu(tetu, nb);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//==========================================================================================================
|
|
|
|
|
|
|
|
|
|
// Partie 3
|
|
|
|
@ -767,7 +753,6 @@ void test1(void){
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// coté etu=========================================================================================================
|
|
|
|
|
// affichage
|
|
|
|
|