|
|
@ -89,29 +89,31 @@ int chargeretudiant(char nomFich[], listetuinfo *tetu[], int tmax){
|
|
|
|
|
|
|
|
|
|
|
|
//enregistrement ========================================================================================
|
|
|
|
//enregistrement ========================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
void enregistrementcarte(FILE *fe, Maillonchoix* b){
|
|
|
|
void enregistrementcarte(FILE *fe, Maillonchoix* carte, int nb){
|
|
|
|
if(b==NULL){return;}
|
|
|
|
if(carte==NULL){return;}
|
|
|
|
fprintf(fe, "%s\n%s\n%d\n%d\n", b->Ville, b->dep, b->decision, b->validation);
|
|
|
|
fprintf(fe, "%s\n%s\n%d\n%d\n", carte->Ville, carte->dep, carte->decision, carte->validation);
|
|
|
|
enregistrementcarte(fe, b.suivant, nb-1);
|
|
|
|
enregistrementcarte(fe, carte->suivant, nb-1);
|
|
|
|
free(b);
|
|
|
|
free(carte);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void enregistrementinfo(FILE *fe, listetuinfo etu){
|
|
|
|
void enregistrementinfo(FILE *fe, listetuinfo etu){
|
|
|
|
Listchoixdept b;
|
|
|
|
Listchoixdept b;
|
|
|
|
int i=0;
|
|
|
|
int i=0;
|
|
|
|
b = etu.carte;
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
enregistrementcarte(fe, b, etu.nbchoix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int enregistrementetudiant(char nomFich[], listetuinfo *tetu[], int nb){
|
|
|
|
int enregistrementetudiant(char nomFich[], listetuinfo *tetu[], int nb){
|
|
|
|
int i=0;
|
|
|
|
int i=0;
|
|
|
|
FILE *fe;
|
|
|
|
FILE *fe;
|
|
|
|
|
|
|
|
listetuinfo etu;
|
|
|
|
fe = fopen( nomFich, "w");
|
|
|
|
fe = fopen( nomFich, "w");
|
|
|
|
if(fe==NULL){printf("<! pb fichier in enregistrementetudiant !>\n");return-1;}
|
|
|
|
if(fe==NULL){printf("<! pb fichier in enregistrementetudiant !>\n");return-1;}
|
|
|
|
fprintf(fe, "%d\n", nb);
|
|
|
|
fprintf(fe, "%d\n", nb);
|
|
|
|
for(i=0; i<nb; i++){
|
|
|
|
for(i=0; i<nb; i++){
|
|
|
|
enregistrementinfo(fe, tetu[i]);
|
|
|
|
etu = tetu[i];
|
|
|
|
|
|
|
|
enregistrementinfo(fe, etu);
|
|
|
|
free(tetu[i]);
|
|
|
|
free(tetu[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fe);
|
|
|
|
fclose(fe);
|
|
|
@ -123,23 +125,23 @@ int enregistrementetudiant(char nomFich[], listetuinfo *tetu[], int nb){
|
|
|
|
|
|
|
|
|
|
|
|
//général fonction for ajouter modifier et supprimer ===========
|
|
|
|
//général fonction for ajouter modifier et supprimer ===========
|
|
|
|
|
|
|
|
|
|
|
|
void affichagedep(MaillonDept* b){
|
|
|
|
void affichagedep(MaillonDept* carte){
|
|
|
|
if(b==NULL){return;}
|
|
|
|
if(carte==NULL){return;}
|
|
|
|
printf("%s", b->departement);
|
|
|
|
printf("%s", carte->departement);
|
|
|
|
affichagedep(b.suivant);
|
|
|
|
affichagedep(carte->suivant);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void affichagecarte(Maillonchoix* carte){
|
|
|
|
void affichagecarte(Maillonchoix* carte){
|
|
|
|
if(carte==NULL){return;}
|
|
|
|
if(carte==NULL){return;}
|
|
|
|
printf("%s - %s\n", carte->Ville, carte->dep);
|
|
|
|
printf("%s - %s\n", carte->Ville, carte->dep);
|
|
|
|
afficherchoix(carte.suivant);
|
|
|
|
afficherchoix(carte->suivant);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void affichageville(Maillon *tville[], int nbville){
|
|
|
|
void affichageville(Maillon *tville[], int nbville){
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
Listdept b;
|
|
|
|
Listdept b;
|
|
|
|
for(i=0; i<nbville; i++){
|
|
|
|
for(i=0; i<nbville; i++){
|
|
|
|
b = tville[i].ldept;
|
|
|
|
b = tville[i]->ldept;
|
|
|
|
printf("%s :\n", tville[i]->Ville);
|
|
|
|
printf("%s :\n", tville[i]->Ville);
|
|
|
|
affichagedep(b);
|
|
|
|
affichagedep(b);
|
|
|
|
printf("\n");
|
|
|
|
printf("\n");
|
|
|
@ -148,20 +150,21 @@ void affichageville(Maillon *tville[], int nbville){
|
|
|
|
|
|
|
|
|
|
|
|
void affichervillechoix(Maillon villechoix){
|
|
|
|
void affichervillechoix(Maillon villechoix){
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
Listdept b;
|
|
|
|
Listdept ldep;
|
|
|
|
b = villechoix.ldept;
|
|
|
|
ldep = villechoix.ldept;
|
|
|
|
printf("%s :\n", villechoix->Ville);
|
|
|
|
printf("%s :\n", villechoix.Ville);
|
|
|
|
affichagedep(b);
|
|
|
|
affichagedep(ldep);
|
|
|
|
printf("\n");
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int cherchelistcorrespond(MaillonDept* dep, char choixdep[]){
|
|
|
|
int cherchelistcorrespond(MaillonDept* dep, char choixdep[]){
|
|
|
|
if(dep==NULL){return -1}
|
|
|
|
if(dep==NULL){return -1;}
|
|
|
|
if(strcmp(dep->departement,choixdep)==0){return 1;}
|
|
|
|
if(strcmp(dep->departement,choixdep)==0){return 1;}
|
|
|
|
return cherchelistcorrespond(dep.suivant);
|
|
|
|
return cherchelistcorrespond(dep->suivant, choixdep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int correspondville(char choixville[], char choixdep[], Maillon *tville[], int nbville){
|
|
|
|
int correspondville(char choixville[], char choixdep[], Maillon *tville[], int nbville){
|
|
|
|
|
|
|
|
int i, ok;
|
|
|
|
Listdept b;
|
|
|
|
Listdept b;
|
|
|
|
for(i=0; i<nbville; i++){
|
|
|
|
for(i=0; i<nbville; i++){
|
|
|
|
if(strcmp(tville[i]->Ville,choixville)==0){
|
|
|
|
if(strcmp(tville[i]->Ville,choixville)==0){
|
|
|
@ -180,7 +183,7 @@ int correspondcarte(char choixville[], char choixdep[], Maillonchoix* carte){
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
correspondcarte(choixville, choixdep, carte.suivant);
|
|
|
|
correspondcarte(choixville, choixdep, carte->suivant);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//ajouter ===============================================================================================
|
|
|
|
//ajouter ===============================================================================================
|
|
|
@ -193,7 +196,7 @@ void choix(Maillon *tville[], int nbville, char choixville[], char choixdep[]){
|
|
|
|
printf("departement : \n");
|
|
|
|
printf("departement : \n");
|
|
|
|
fgets(choixdep, 31, stdin);
|
|
|
|
fgets(choixdep, 31, stdin);
|
|
|
|
choixdep[strlen(choixdep)-1]='\0';
|
|
|
|
choixdep[strlen(choixdep)-1]='\0';
|
|
|
|
ok = correspondville(choixville, choixdep, tville[i], nbville);
|
|
|
|
ok = correspondville(choixville, choixdep, tville, nbville);
|
|
|
|
while(ok!=1){
|
|
|
|
while(ok!=1){
|
|
|
|
printf("ville : \n");
|
|
|
|
printf("ville : \n");
|
|
|
|
fgets(choixville, 31, stdin);
|
|
|
|
fgets(choixville, 31, stdin);
|
|
|
@ -201,28 +204,28 @@ void choix(Maillon *tville[], int nbville, char choixville[], char choixdep[]){
|
|
|
|
printf("departement : \n");
|
|
|
|
printf("departement : \n");
|
|
|
|
fgets(choixdep, 31, stdin);
|
|
|
|
fgets(choixdep, 31, stdin);
|
|
|
|
choixdep[strlen(choixdep)-1]='\0';
|
|
|
|
choixdep[strlen(choixdep)-1]='\0';
|
|
|
|
ok = correspondville(choixville, choixdep, tville[i], nbville);
|
|
|
|
ok = correspondville(choixville, choixdep, tville, nbville);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Listchoixdept ajoutercarte(Maillonchoix* a, char choixville, char choixdep){
|
|
|
|
Listchoixdept ajoutercarte(Maillonchoix* a, char choixville[], char choixdep[]){
|
|
|
|
Maillonchoix* carte;
|
|
|
|
Maillonchoix* carte;
|
|
|
|
carte = (Maillonchoix*)malloc(sizeof(Maillonchoix));
|
|
|
|
carte = (Maillonchoix*)malloc(sizeof(Maillonchoix));
|
|
|
|
if(carte==NULL){printf("<! erreur malloc in ajoutercarte !>\n");exit(1);}
|
|
|
|
if(carte==NULL){printf("<! erreur malloc in ajoutercarte !>\n");exit(1);}
|
|
|
|
strcpy(carte->Ville,choixville);
|
|
|
|
strcpy(carte->Ville,choixville);
|
|
|
|
strcpy(carte->departement,choixdep);
|
|
|
|
strcpy(carte->dep,choixdep);
|
|
|
|
carte->decision=0;
|
|
|
|
carte->decision=0;
|
|
|
|
carte->validation=0;
|
|
|
|
carte->validation=0;
|
|
|
|
carte->suviant=a;
|
|
|
|
carte->suivant=a;
|
|
|
|
return carte;
|
|
|
|
return carte;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int allajoutprocess(Maillon *tville[], listetuinfo etu, int nbville){
|
|
|
|
int allajoutprocess(Maillon *tville[], listetuinfo etu, int nbville){
|
|
|
|
int i;
|
|
|
|
int i, ok;
|
|
|
|
Listchoixdept b;
|
|
|
|
Listchoixdept b;
|
|
|
|
b = etu.carte;
|
|
|
|
b = etu.carte;
|
|
|
|
char choixville[31], choixdep[31];
|
|
|
|
char choixville[31], choixdep[31];
|
|
|
|
afficheville(tville, nbville);
|
|
|
|
affichageville(tville, nbville);
|
|
|
|
choix(tville, nbville, choixville, choixdep);
|
|
|
|
choix(tville, nbville, choixville, choixdep);
|
|
|
|
ok = correspondcarte(choixville, choixdep, b);
|
|
|
|
ok = correspondcarte(choixville, choixdep, b);
|
|
|
|
if(ok==0){b = ajoutercarte(b, choixville, choixdep);}
|
|
|
|
if(ok==0){b = ajoutercarte(b, choixville, choixdep);}
|
|
|
@ -232,6 +235,7 @@ int allajoutprocess(Maillon *tville[], listetuinfo etu, int nbville){
|
|
|
|
//modifier ==============================================================================================
|
|
|
|
//modifier ==============================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
void choix2(Listchoixdept lcarte, char choixville[], char choixdep[]){
|
|
|
|
void choix2(Listchoixdept lcarte, char choixville[], char choixdep[]){
|
|
|
|
|
|
|
|
int ok;
|
|
|
|
printf("ville : \n");
|
|
|
|
printf("ville : \n");
|
|
|
|
fgets(choixville, 31, stdin);
|
|
|
|
fgets(choixville, 31, stdin);
|
|
|
|
choixville[strlen(choixville)-1]='\0';
|
|
|
|
choixville[strlen(choixville)-1]='\0';
|
|
|
@ -250,7 +254,7 @@ void choix2(Listchoixdept lcarte, char choixville[], char choixdep[]){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void choixdep(char choixville[], char choixdep[], Maillon *tville[], int nbville){
|
|
|
|
void fchoixdep(char choixville[], char choixdep[], Maillon *tville[], int nbville){
|
|
|
|
int ok;
|
|
|
|
int ok;
|
|
|
|
printf("\n< quel departement voulez vous choisir ? >\n==>");
|
|
|
|
printf("\n< quel departement voulez vous choisir ? >\n==>");
|
|
|
|
fgets(choixdep, 31, stdin);
|
|
|
|
fgets(choixdep, 31, stdin);
|
|
|
@ -264,22 +268,22 @@ void choixdep(char choixville[], char choixdep[], Maillon *tville[], int nbville
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
listetuinfo choixmodifcarte(char choixville[], char choixdep[], Maillon *tville[], int nbville){
|
|
|
|
Maillonchoix choixmodifcarte(Maillonchoix dep, char choixville[], char choixdep[]){
|
|
|
|
if(b==NULL){return -1;}
|
|
|
|
Maillonchoix dep;
|
|
|
|
Listdept dep;
|
|
|
|
if(dep==NULL){exit(1);}
|
|
|
|
if(strcmp(b->Ville,choixville)==0){
|
|
|
|
if(strcmp(dep->Ville,choixville)==0){
|
|
|
|
if(strcmp(b->dep,choixdep)==0){
|
|
|
|
if(strcmp(dep->dep,choixdep)==0){
|
|
|
|
choixdep(choixville, choixdep, tville, nbville);
|
|
|
|
fchoixdep(choixville, choixdep, tville, nbville);
|
|
|
|
b->dep=choixville;
|
|
|
|
dep->dep=choixville;
|
|
|
|
return b;
|
|
|
|
return dep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b->suivant = choixmodifcarte(b.suivant, choixville, choixdep);
|
|
|
|
dep->suivant = choixmodifcarte(dep.suivant, choixville, choixdep);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int correspondvilleonly(char choixville[], Maillon ville){
|
|
|
|
int correspondvilleonly(char choixville[], Maillon ville){
|
|
|
|
Listdept b;
|
|
|
|
Listdept b;
|
|
|
|
if(strcmp(ville->Ville,choixville)==0){
|
|
|
|
if(strcmp(ville.Ville,choixville)==0){
|
|
|
|
affichervillechoix(ville);
|
|
|
|
affichervillechoix(ville);
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -295,8 +299,9 @@ void modificationcarte(listetuinfo etu, Maillon *tville[], int nbville){
|
|
|
|
for(i=0; i<nbville; i++){
|
|
|
|
for(i=0; i<nbville; i++){
|
|
|
|
ok = correspondvilleonly(choixville, tville[i]);
|
|
|
|
ok = correspondvilleonly(choixville, tville[i]);
|
|
|
|
if(ok==1){
|
|
|
|
if(ok==1){
|
|
|
|
choixdep(choixville, choixdep, tville, nbville);
|
|
|
|
fchoixdep(choixville, choixdep, tville, nbville);
|
|
|
|
lcarte = choixmodifcarte(choixville, choixdep, tville, nbville);
|
|
|
|
lcarte = choixmodifcarte(choixville, choixdep, tville, nbville);
|
|
|
|
|
|
|
|
etu.carte=lcarte;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{printf("\t< choix deja existant >\n");}
|
|
|
|
else{printf("\t< choix deja existant >\n");}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -304,9 +309,9 @@ void modificationcarte(listetuinfo etu, Maillon *tville[], int nbville){
|
|
|
|
|
|
|
|
|
|
|
|
//supprimer =============================================================================================
|
|
|
|
//supprimer =============================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
Maillonchoix suppressioncartechoix(char choixville[], char choixdep[], Maillonchoix carte){
|
|
|
|
Maillonchoix suppressioncartechoix(char choixville[], char choixdep[], Maillonchoix* carte){
|
|
|
|
Maillon tmp;
|
|
|
|
Maillonchoix* premier, tmp;
|
|
|
|
if(carte==NULL){return;}
|
|
|
|
if(carte==NULL){exit(1);}
|
|
|
|
if(strcmp(carte->Ville,choixville)==0){
|
|
|
|
if(strcmp(carte->Ville,choixville)==0){
|
|
|
|
if(strcmp(choixdep,carte->dep)==0){
|
|
|
|
if(strcmp(choixdep,carte->dep)==0){
|
|
|
|
tmp=carte->suivant;
|
|
|
|
tmp=carte->suivant;
|
|
|
@ -314,10 +319,10 @@ Maillonchoix suppressioncartechoix(char choixville[], char choixdep[], Maillonch
|
|
|
|
return tmp;
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
suppressioncartechoix(choixville, choixdep, carte.suivant);
|
|
|
|
carte = suppressioncartechoix(choixville, choixdep, carte.suivant);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void suppcarte(listetuinfo etu,){
|
|
|
|
void suppcarte(listetuinfo etu){
|
|
|
|
int i, ok;
|
|
|
|
int i, ok;
|
|
|
|
char choixville[31], choixdep[31];
|
|
|
|
char choixville[31], choixdep[31];
|
|
|
|
Listchoixdept lcarte;
|
|
|
|
Listchoixdept lcarte;
|
|
|
|