Flavien BOUHAMDANI 3 years ago
commit fdd23a726c

BIN
sae

Binary file not shown.

@ -418,7 +418,6 @@ void test(void){
menuPrincipal(tabVille, nb, tetu, nbEtu, departementVille);
}
// Partie 2
//chargement ======================================================================================================================================================================
@ -463,8 +462,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){
@ -474,18 +487,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);
@ -497,40 +510,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;}
@ -538,12 +556,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;}
}
@ -551,7 +570,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){
@ -561,9 +580,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);
@ -595,7 +616,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;
@ -605,7 +626,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 ==============================================================================================================================================================
@ -629,42 +650,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;
@ -675,7 +710,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");}
@ -684,86 +719,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;
@ -774,9 +756,11 @@ void test1(void){
}
//==========================================================================================================
*/
// Partie 3
DepartementVille* recupererEtudiantsDepartementVille(listetuinfo* etudiants[], int nbEtudiants, char* ville, char* dep) {
DepartementVille* departementVille = malloc(sizeof(DepartementVille));
departementVille->nbEtudiants = 0;
@ -821,8 +805,8 @@ void trierDepartementVille(DepartementVille* departementVille, int nbElements) {
void comparerEtudiants(DepartementVille* departementVille, listetuinfo* etudiants, int nbPlaces) {
for (int i = 0; i < departementVille->nbEtudiants; i++) {
// si l'étudiant a une moyenne inférieure à 10, mettre sa variable "decision" à 0
if (departementVille->etudiants[i]->moyenne < 10) departementVille->etudiants[i]->carte->decision = 0;
// si l'étudiant a une moyenne inférieure à 10, mettre sa variable "decision" à -1
if (departementVille->etudiants[i]->moyenne < 10) departementVille->etudiants[i]->carte->decision = -1;
// sinon, si l'index de l'étudiant est inférieur ou égal au nombre de places disponibles, mettre sa variable "decision" à 1
else if (i < nbPlaces) departementVille->etudiants[i]->carte->decision = 1;
// sinon, mettre sa variable "decision" à 2
@ -848,6 +832,8 @@ void afficherDepartementVille(DepartementVille* departementVille) {
}
}
// Partie 4
/*
@ -862,12 +848,11 @@ void afficherDepartementVille(DepartementVille* departementVille) {
-
-
*/
// coté etu=========================================================================================================
// affichage
/*
void affichagedepresultat(Maillonchoix* carte){
if(carte==NULL){return;}
if(carte->decision==1){
@ -897,117 +882,4 @@ void validation(char choixville[], char choixdep[], Maillonchoix* carte, int *ok
validation(choixville, choixdep, carte.suivant, ok);
if(ok==1){
if(carte.decision==1){
carte.validation=-1;
miseajourindep( lplace, nbplace, etu);
}
}
}
void enregistrementvalidation(char choixville[], char choixdep[], Maillonchoix* carte, int *ok, char nomFich[], listetuinfo *tetu[], int nb){
int ok;
validation( choixville, choixdep, carte, &ok);
enregistrementetudiants( nomFich, tetu, nb);
}
// -> mise a jour
Maillonatt miseajourfile(Maillonatt place, int nbplace, listetuinfo etu){
if(place==NULL){exit(1);}
if(place.munc==etu.numeroetu){
Maillonatt temp;
temp=place.suivant;
free(place);
return temp;
}
miseajourfile(place.suivant, nbplace-1);
}
int miseajouratt(Maillonatt place, int nbplace){
if(place==NULL){return;}
if(nbplace==0){return;}
if(place.decision==2){
place.decision==1;
}
miseajouratt(place.suivant, nbplace-1);
}
void miseajourindep(Maillonatt lplace, int nbplace, listetuinfo etu){
lpace = miseajourfile(lplace, nbplace, etu);
miseajouratt(lplace, nbplace);
}
// coté dep=============================================================================================================
// affichage dep
void affichageonlyadmis(Maillonatt etuatt){
if(etuatt==NULL){return;}
if(etuatt.decision==1){
printf("%d %s %s\n" etuatt.numc, etuatt.nom, etuatt.prenom);
}
affichageonlyadmis(etuatt.suivant);
}
void affichageonlyatt(Maillonatt etuatt){
if(etuatt==NULL){return;}
if(etuatt.decision==1){
printf("%d %s %s\n" etuatt.numc, etuatt.nom, etuatt.prenom);
}
affichageonlyatt(etuatt.suivant);
}
//chercher present en admission ========================================================================================
void chercheretuadmisindep(char choixnom[], char nomprenom[], Maillonatt etuatt){
if(etuatt==NULL){printf("erreur de recherche\n");return;}
if(strcmp(etuatt.nom,choixnom)==0){
if(strcmp(etuatt.prenom,choixprenom)==0){
if(etuatt.decision==1){printf("%s %s est admis\n", etuatt.nom, etuatt.prenom);return;}
if(etuatt.decision==2){printf("%s %s est en attente\n", etuatt.nom, etuatt.prenom);return;}
if(etuatt.decision==-1){printf("%s %s est refusé\n", etuatt.nom, etuatt.prenom);return;}
}
}
chercheretuadmisindep(choixnom, choixprenom, etuatt.suivant);
}
*/
// Général (menu et ce qui en ai relié)
/*
questionadmin(){
printf("\nQuel numéro détudiant ?\n==>");
scanf("%d%*c", &choix);
printf("\n");
}
int menu(void){
//charger
int i=0, choix;
while(i!=1){
printf("\n\tmenu\n\n");
printf("1\tutilisateur\n");
printf("2\tadmin\n");
printf("3\tresponsable d'admission\n");
printf("\nQuel est votre choix ?\n==>");
scanf("%d%*c", &choix);
printf("\n");
if(choix==1){
}
if(choix==2){
}
if(choix==3){
}
if(choix<1 || choix>6){
printf("mauvaise saisie\n");
}
}
//enregister
return 1;
}
*/
*/

@ -52,10 +52,8 @@ void ajoutIUT(VilleIUT *tIUT[], int *nbville, int taillemax);
Listdept suppressionDept(Listdept d, char rechercheDep[31]);
void supprDepartement(VilleIUT *tville[], int* nbville);
void menuP1Utilisateur(VilleIUT *v[], int nb);
void sauvegardeDep(Listdept d, FILE *fs);
void sauvegarde(VilleIUT *tville[], int nbville);
void test(void);
// Partie 2
@ -68,25 +66,48 @@ typedef struct listchoix{
}Maillonchoix, *Listchoixdept;
typedef struct{
int numeroetu;
char nometu[21];
char prenometu[21];
int notes[4];
int nbchoix;
Listchoixdept carte;
float moyenne;
int numeroetu;
char nometu[21];
char prenometu[21];
int notes[4];
int nbchoix;
float moyenne; // partie 3
Listchoixdept carte;
}listetuinfo;
Listchoixdept listvide(void);
Listchoixdept lireCarte(FILE *fe, int nbchoix);
listetuinfo lireEtu(FILE *fe);
int chargeretudiant(char nomFich[], listetuinfo *tetu[], int tmax);
void affichealletu(listetuinfo *tetu[], int nb);
int recherdicoetu(listetuinfo *tetu[], int nb, int num);
void enregistrementcarte(FILE *fe, Maillonchoix* carte, int nb);
void enregistrementinfo(FILE *fe, listetuinfo *etu);
int enregistrementetudiants(char nomFich[], listetuinfo *tetu[], int nb);
void affichagecarte(Listchoixdept c);
void affichageetu(listetuinfo a);
void affichage(Listchoixdept c);
void affichealletu(listetuinfo *tetu[], int nb);
int cherchelistcorrespond(MaillonDept* dep, char choixdep[]);
int correspondville(char choixville[], char choixdep[], VilleIUT *tville[], int nbville);
int correspondcarte(char choixville[], char choixdep[], Listchoixdept carte);
void choix(VilleIUT *tville[], int nbville, char choixville[], char choixdep[]);
Listchoixdept ajoutercarte(Maillonchoix* a, char choixville[], char choixdep[]);
void allajoutprocess(VilleIUT *tville[], listetuinfo etu, int nbville);
void choix2(Listchoixdept lcarte, char choixville[], char choixdep[]);
void fchoixdep(char choixville[], char choixdep[], VilleIUT *tville[], int nbville);
Listchoixdept choixmodifcarte(Listchoixdept dep, char choixville[], char choixdep[], VilleIUT *tville[], int nbville);
void affichagedep(MaillonDept* carte);
void affichervillechoix(VilleIUT *villechoix);
int correspondvilleonly(char choixville[], VilleIUT *ville);
void modificationcarte(listetuinfo etu, VilleIUT *tville[], int nbville);
Maillonchoix* suppressioncartechoix(char choixville[], char choixdep[], Listchoixdept carte);
void suppcarte(listetuinfo *etu);
// Partie 3
typedef struct {
char ville[31];
char departement[31];
@ -111,8 +132,9 @@ typedef struct listatt{
struct listatt* suivant;
}Maillonatt;
void test(void);
void test1(void);
void menuP1Utilisateur(VilleIUT *v[], int nb);
void menuPrincipal(VilleIUT *tabVille[], int nb, listetuinfo *tetu[], int nbEtu, DepartementVille* departementVille);
void menuP1Administrateur(VilleIUT *tabVille[], int nb, listetuinfo *tetu[], int nbEtu, DepartementVille* departementVille);
void menuP1Administrateur(VilleIUT *tabVille[], int nb, listetuinfo *tetu[], int nbEtu, DepartementVille* departementVille);

BIN
sase

Binary file not shown.
Loading…
Cancel
Save