master
Alexis LAURENT 2 years ago
parent 33a34bcc53
commit 2998e7ae12

211
SAE.c

@ -108,7 +108,7 @@ int menuAdminAffiche(void)
return choix; return choix;
} }
void gestionMenu(void) void gestionMenu(VilleIUT **tiut, int nbEle)
{ {
int choix; int choix;
while(1) while(1)
@ -149,7 +149,7 @@ void gestionMenu(void)
} }
} }
int gestionMenuAdmin(void) int gestionMenuAdmin(VilleIUT **tiut, int nbEle)
{ {
int choix; int choix;
if (!motdepasseVerif()) if (!motdepasseVerif())
@ -195,7 +195,11 @@ int gestionMenuAdmin(void)
void global(void) void global(void)
{ {
gestionMenu(); VilleIUT *tiut[30];
int nbEle;
//nbEle = chargement(tiut,30);
triEchange(tiut, nbEle);
gestionMenu(tiut, nbEle);
} }
void AffichageVille(VilleIUT **tiut, int nbEle) void AffichageVille(VilleIUT **tiut, int nbEle)
@ -204,7 +208,7 @@ void AffichageVille(VilleIUT **tiut, int nbEle)
printf("\tIUT par ville :"); printf("\tIUT par ville :");
for(i=0;i<nbEle;i++) for(i=0;i<nbEle;i++)
{ {
printf("- %s\n",tiut[i]->ville); printf("- %s",tiut[i]->ville);
} }
} }
@ -214,7 +218,8 @@ void AffichageGlobalDepVille(VilleIUT **tiut, int nbEle)
printf("\tDépartement par IUT :\n"); printf("\tDépartement par IUT :\n");
for(i=0;i<nbEle;i++) for(i=0;i<nbEle;i++)
{ {
printf("- %s :\n\t",tiut[i]->ville); ville(tiut[i]->ville);
printf(" :\n\t");
while(tiut[i]->idDept != NULL) while(tiut[i]->idDept != NULL)
{ {
printf("|%s|\n",tiut[i]->idDept->departement); printf("|%s|\n",tiut[i]->idDept->departement);
@ -228,30 +233,37 @@ void AffichageNbplaceDept(VilleIUT **tiut, int nbEle)
int pos; int pos;
for (pos = 0; pos < nbEle; pos++) for (pos = 0; pos < nbEle; pos++)
{ {
AffichageVille(tiut[pos]->ville);
printf(" -> \t");
while(tiut[pos]->idDept->suiv != NULL && pos < nbEle) while(tiut[pos]->idDept->suiv != NULL && pos < nbEle)
{ {
printf("%s -> |%s, %d places|\n",tiut[pos]->ville,tiut[pos]->idDept->departement, tiut[pos]->idDept->nbPers); printf("|%s, %d places|\n\t",tiut[pos]->idDept->departement, tiut[pos]->idDept->nbPers);
tiut[pos]->idDept = tiut[pos]->idDept->suiv; tiut[pos]->idDept = tiut[pos]->idDept->suiv;
} }
printf("\n");
} }
} }
int rechVille(VilleIUT **tiut, int nbEle, char code[], int *trouve) int rechVille(VilleIUT **tiut, int nbEle, char code[], int *trouve)
{ {
int i; int inf = 0, sup = nbEle - 1, m;
while(i<nbEle) while(inf <= sup)
{ {
if (strcmp(code,tiut[i]->ville)==0) m = (inf + sup)/2;
if (strcmp(tiut[r]->ville, code)==0)
{
*trouve = 1; *trouve = 1;
i = i + 1; return m;
}
if (strcmp(tiut[r]->ville, code)>0)
sup = m - 1;
else inf = m + 1;
} }
return i;
} }
void AffichageNbplaceDeptVille(VilleIUT **tiut, int nbEle) void AffichageNbplaceDeptVille(VilleIUT **tiut, int nbEle)
{ {
MaillonDept *aux; MaillonDept *aux;
aux =(MaillonDept *)malloc(sizeof(MaillonDept));
char code[30]; char code[30];
int pos,trouve = 0; int pos,trouve = 0;
while(1) while(1)
@ -259,7 +271,6 @@ void AffichageNbplaceDeptVille(VilleIUT **tiut, int nbEle)
printf("IUT : "); printf("IUT : ");
scanf("%s",code); scanf("%s",code);
pos = rechVille(tiut, nbEle, code,&trouve); pos = rechVille(tiut, nbEle, code,&trouve);
aux = tiut[pos]->idDept;
if (trouve == 1) if (trouve == 1)
{ {
@ -268,27 +279,18 @@ void AffichageNbplaceDeptVille(VilleIUT **tiut, int nbEle)
printf("Département : "); printf("Département : ");
scanf("%s",code); scanf("%s",code);
trouve = 0; trouve = 0;
while(aux->suiv != NULL) aux = rechercheDept(tiut[pos]->idDept, code);
{ if (aux == NULL)
if (strcmp(tiut[pos]->idDept->departement, code)==0)
{
printf("%s -> |%s, %d places|\n",tiut[pos]->ville,aux->departement, aux->nbPers);
trouve = 1;
break;
}
aux = aux->suiv;
}
if (trouve == 0)
printf("Département non présent à l'iut de %s",tiut[pos]->ville); printf("Département non présent à l'iut de %s",tiut[pos]->ville);
if (aux != NULL)
printf("%s -> |%s, %d places|\n",tiut[pos]->ville,aux->departement, aux->nbPers);
printf("Saisi Département :\n");
if(!verifSelection()) if(!verifSelection())
break; break;
aux = tiut[pos]->idDept;
} }
} }
else printf("Cette Ville n'as pas d'IUT\n"); else printf("%s n'a pas d'IUT\n",code);;
} }
free(aux);
} }
void AffichageDepVille(VilleIUT **tiut, int nbEle) void AffichageDepVille(VilleIUT **tiut, int nbEle)
@ -306,7 +308,8 @@ void AffichageDepVille(VilleIUT **tiut, int nbEle)
affichageListeDept(tiut[pos]->idDept); affichageListeDept(tiut[pos]->idDept);
} }
if (trouve == 0) if (trouve == 0)
printf("Département non présent à l'iut de %s",tiut[pos]->ville); printf("%s n'a pas d'IUT\n",code);
printf("Saisi Ville :\n");
if(!verifSelection()) if(!verifSelection())
break; break;
} }
@ -315,7 +318,6 @@ void AffichageDepVille(VilleIUT **tiut, int nbEle)
void AffichageDeptVille(VilleIUT **tiut, int nbEle) void AffichageDeptVille(VilleIUT **tiut, int nbEle)
{ {
MaillonDept *aux; MaillonDept *aux;
aux =(MaillonDept *)malloc(sizeof(MaillonDept));
char code[30]; char code[30];
int pos = 0, nbocc = 0; int pos = 0, nbocc = 0;
while(1) while(1)
@ -325,20 +327,16 @@ void AffichageDeptVille(VilleIUT **tiut, int nbEle)
printf("\nIUT ayant un département %s : \n",code); printf("\nIUT ayant un département %s : \n",code);
for(pos = 0; pos < nbEle; pos++) for(pos = 0; pos < nbEle; pos++)
{ {
aux = tiut[pos]->idDept; aux = rechercheDept(tiut[pos]->idDept, code);
while(aux != NULL) if(aux != NULL)
{ {
if(strcmp(aux->departement, code)==0) AffichageVille(tiut[pos]->ville);
{ nbocc = nbocc + 1;
affichageListeDept(aux);
nbocc = nbocc + 1;
break;
}
aux = aux->suiv;
} }
} }
if (nbocc == 0) if (nbocc == 0)
printf("aucun département %s est présent en France\n", code); printf("aucun département %s est présent en France\n", code);
printf("Saisi Département :\n");
if(!verifSelection()) if(!verifSelection())
break; break;
} }
@ -347,9 +345,12 @@ void AffichageDeptVille(VilleIUT **tiut, int nbEle)
void AffichageGlobalIUT(VilleIUT **tiut, int nbEle) void AffichageGlobalIUT(VilleIUT **tiut, int nbEle)
{ {
int pos = 0; int pos = 0;
printf("Ville : \t");
while(pos < nbEle) while(pos < nbEle)
{ {
printf("Ville : %s\n",tiut[pos]->ville); AffichageVille(VilleIUT)
printf(" :\n\t");
printf("Département:\tNombre de places:\tNom du Responsable:\n\t");
affichageListeDept(tiut[pos]->idDept); affichageListeDept(tiut[pos]->idDept);
pos = pos + 1; pos = pos + 1;
printf("\n"); printf("\n");
@ -359,7 +360,6 @@ void AffichageGlobalIUT(VilleIUT **tiut, int nbEle)
void MiseAJourNbPlace(VilleIUT **tiut, int nbEle) void MiseAJourNbPlace(VilleIUT **tiut, int nbEle)
{ {
MaillonDept *aux; MaillonDept *aux;
aux =(MaillonDept *)malloc(sizeof(MaillonDept));
int nouvNbPlace, pos, trouve; int nouvNbPlace, pos, trouve;
char code[30]; char code[30];
while(1) while(1)
@ -369,38 +369,39 @@ void MiseAJourNbPlace(VilleIUT **tiut, int nbEle)
pos = rechVille(tiut, nbEle, code,&trouve); pos = rechVille(tiut, nbEle, code,&trouve);
if (trouve == 1) if (trouve == 1)
{ {
aux = tiut[pos]->idDept;
while(1) while(1)
{ {
printf("Département : "); printf("Département : ");
scanf("%s",code); scanf("%s",code);
while(tiut[pos]->idDept->suiv != NULL) aux = rechercheDept(tiut[pos]->idDept, code);
if (aux != NULL)
{ {
if (strcmp(tiut[pos]->idDept->departement, code)==0) printf("Ancien nombre de places : %d",aux->nbPers);
{ printf("Nouveau nombre de places : ", nouvNbPlace);
printf("Ancien nombre de places : %d",tiut[pos]->idDept->nbPers); scanf("%d", &nouvNbPlace);
printf("Nouveau nombre de places : ", nouvNbPlace); aux->nbPers = nouvNbPlace;
scanf("%d", &nouvNbPlace); printf("Mise à jour effectuer avec succès !");
tiut[pos]->idDept->nbPers = nouvNbPlace; break;
printf("Mise à jour effectuer avec succès !");
break;
}
tiut[pos]->idDept = tiut[pos]->idDept->suiv;
} }
if (trouve == 0) if (aux == NULL)
printf("Département non présent à l'iut de %s",tiut[pos]->ville); printf("Département non présent à l'iut de %s",tiut[pos]->ville);
printf("Saisi Département :\n");
if(!verifSelection()) if(!verifSelection())
break; break;
tiut[pos]->idDept = aux;
} }
} }
if (trouve == 0)
printf("Cet ville n'a pas d'IUT\n");
printf("Saisi Ville :\n");
if(!verifSelection())
break;
} }
free(aux);
} }
void creationDept(VilleIUT **tiut, int nbEle) void creationDept(VilleIUT **tiut, int nbEle)
{ {
MaillonDept *aux;
char code[30], nom[30]; char code[30], nom[30];
int trouve, pos, nbP; int trouve, pos, nbP;
while(1) while(1)
@ -414,9 +415,11 @@ void creationDept(VilleIUT **tiut, int nbEle)
{ {
printf("Nom du Département : "); printf("Nom du Département : ");
scanf("%s", code); scanf("%s", code);
if (recherche(tiut[pos]->idDept, code)) aux = rechercheDept(tiut[pos]->idDept, code)
if (aux != NULL)
printf("Département déjà existant"); printf("Département déjà existant");
if (!recherche(tiut[pos]->idDept, code)) if (aux == NULL)
{
printf("Nom du Responsable du Département de %s : ",code); printf("Nom du Responsable du Département de %s : ",code);
fgets(nom,30,stdin); fgets(nom,30,stdin);
nom[strlen(nom)-1] = "\0"; nom[strlen(nom)-1] = "\0";
@ -424,12 +427,15 @@ void creationDept(VilleIUT **tiut, int nbEle)
scanf("%d", nbP); scanf("%d", nbP);
tiut[pos]->idDept = inserer(tiut[pos]->idDept,code,nom,nbP); tiut[pos]->idDept = inserer(tiut[pos]->idDept,code,nom,nbP);
printf("insertion du département %s effectuer \n", code); printf("insertion du département %s effectuer \n", code);
}
printf("Saisi Département :\n");
if (!verifSelection()) if (!verifSelection())
break; break;
} }
} }
if (trouve == 0) if (trouve == 0)
printf("Cet ville n'a pas d'IUT\n"); printf("Cet ville n'a pas d'IUT\n");
printf("Saisi Ville :\n");
if(!verifSelection()) if(!verifSelection())
break; break;
@ -439,6 +445,7 @@ void creationDept(VilleIUT **tiut, int nbEle)
void suppressionDept(VilleIUT **tiut, int nbEle) void suppressionDept(VilleIUT **tiut, int nbEle)
{ {
MaillonDept *aux;
char code[30]; char code[30];
int trouve, pos, nbP; int trouve, pos, nbP;
while(1) while(1)
@ -450,21 +457,28 @@ void suppressionDept(VilleIUT **tiut, int nbEle)
{ {
printf("Nom du Département : "); printf("Nom du Département : ");
scanf("%s", code); scanf("%s", code);
if (recherche(tiut[pos]->idDept, code)) aux = rechercheDept(tiut[pos]->idDept, code)
if (aux != NULL)
if (confirmationSup()) if (confirmationSup())
tiut[pos]->idDept = supprimer(tiut[pos]->idDept, code); tiut[pos]->idDept = supprimer(tiut[pos]->idDept, code);
if (!recherche(tiut[pos]->idDept, code)) if (aux == NULL)
printf("Ce Département n'existe pas dans l'IUT de %s \n",tiut[pos]->ville); printf("Ce Département n'existe pas dans l'IUT de %s \n",tiut[pos]->ville);
printf("Saisi Département :\n");
if (!verifSelection()) if (!verifSelection())
break; break;
} }
if (trouve == 0)
printf("Cet ville n'a pas d'IUT\n");
printf("Saisi Ville :\n");
if (!verifSelection())
break;
} }
} }
void modifChefDept(VilleIUT **tiut, int nbEle) void modifChefDept(VilleIUT **tiut, int nbEle)
{ {
MaillonDept *aux;
char code[30]; char code[30];
int trouve, pos, nbP; int trouve, pos, nbP;
while(1) while(1)
@ -474,34 +488,62 @@ void modifChefDept(VilleIUT **tiut, int nbEle)
pos = rechVille(tiut, nbEle, code, &trouve); pos = rechVille(tiut, nbEle, code, &trouve);
if (trouve == 1) if (trouve == 1)
{ {
printf("Nom du Département : "); while(1)
scanf("%s", code); printf("Nom du Département : ");
if (recherche(tiut[pos]->idDept, code)) scanf("%s", code);
{ aux = rechercheDept(tiut[pos]->idDept, code);
if (aux != NULL)
while(tiut[pos]->idDept->suiv != NULL)
{ {
if(strcmp(tiut[pos]->idDept->departement, code) == 1) printf("Nom de l'ancien chef de département %s de %s : %s\n",aux->departement, tiut[pos]->ville,aux->responsable);
{ printf("Nom du nouveau chef de département %s de %s :",aux->departement, tiut[pos]->ville);
printf("Nom de l'ancien chef de département %s de %s : %s\n",tiut[pos]->idDept->departement, tiut[pos]->ville,tiut[pos]->idDept->responsable); fgets(code,30,stdin);
printf("nom du nouveau chef de département %s de %s :",tiut[pos]->idDept->departement, tiut[pos]->ville); code[strlen(code)-1] = "\0";
fgets(code,30,stdin); strcpy(code, aux->responsable);
code[strlen(code)-1] = "\0"; printf("Chef de département : %s\n",tiut[pos]->idDept->responsable);
strcpy(code, tiut[pos]->idDept->responsable);
printf("Chef de département : %s\n",tiut[pos]->idDept->responsable);
}
} }
} if (aux == NULL)
if (!recherche(tiut[pos]->idDept, code)) printf("Ce Département n'existe pas dans l'IUT de %s \n",tiut[pos]->ville);
printf("Ce Département n'existe pas dans l'IUT de %s \n",tiut[pos]->ville); printf("Saisi Département :\n");
if (!verifSelection()) if (!verifSelection())
break; break;
} }
if (trouve == 0)
printf("Cet ville n'a pas d'IUT\n");
printf("Saisi Ville :\n");
if (!verifSelection())
break;
} }
} }
void triEchange(VilleIUT **tiut, int nbEle)
{
int pge;
while(nbEle>1)
{
pge = plusGrand(tiut, nbEle);
echanger(tiut,pge,nb-1);
nb = nb - 1;
}
}
int plusGrand(VilleIUT **tiut, int nbEle)
{
int pge = 0, i;
for (i = 1, i < nb, i++)
if (strcmp(tiut[i]->ville,tiut[pge]->ville)>0)
pge = 1;
return pge;
}
void echanger(VilleIUT **tiut, int i, int j)
{
VilleIUT *aux;
aux = tiut[i];
tiut[i] = tiut[j];
tiut[j] = aux;
}
void clearpage(void) void clearpage(void)
{ {
char entre; char entre;
@ -509,3 +551,6 @@ void clearpage(void)
scanf("%*c%c", &entre); scanf("%*c%c", &entre);
system("clear"); system("clear");
} }

79
SAE.h

@ -12,7 +12,7 @@ typedef struct maillon
struct maillon *suiv; struct maillon *suiv;
}MaillonDept; }MaillonDept;
typedef MaillonDept* Liste; typedef MaillonDept* ListeDept;
typedef struct typedef struct
{ {
@ -20,6 +20,25 @@ typedef struct
MaillonDept *idDept; MaillonDept *idDept;
}VilleIUT; }VilleIUT;
typedef struct maillonEtu
{
char iutCandid[30];
char departement[30];
int decisionDept;
int decisionCandid;
struct maillonEtu *suiv;
}MaillonCandid, *ListeDeptCandid;
typedef struct
{
int id;
char nom[30];
char prenom[30];
int note[4];
MaillonCandid *idCandDept;
}Candidat;
bool motdepasseVerif(void); bool motdepasseVerif(void);
bool verifQuit(void); bool verifQuit(void);
@ -28,8 +47,62 @@ int menuUtilisateurAffiche(void);
int menuAdminAffiche(void); int menuAdminAffiche(void);
void gestionMenu(void); void gestionMenu(VilleIUT **tiut, int nbEle);
int gestionMenuAdmin(VilleIUT **tiut, int nbEle);
void global(void);
void AffichageVille(VilleIUT **tiut, int nbEle);
void AffichageGlobalDepVille(VilleIUT **tiut, int nbEle);
void AffichageNbplaceDept(VilleIUT **tiut, int nbEle);
int rechVille(VilleIUT **tiut, int nbEle, char code[], int *trouve);
void AffichageNbplaceDeptVille(VilleIUT **tiut, int nbEle);
void AffichageDepVille(VilleIUT **tiut, int nbEle);
void AffichageDeptVille(VilleIUT **tiut, int nbEle);
void AffichageGlobalIUT(VilleIUT **tiut, int nbEle);
int gestionMenuAdmin(void); void MiseAJourNbPlace(VilleIUT **tiut, int nbEle);
void creationDept(VilleIUT **tiut, int nbEle);
void suppressionDept(VilleIUT **tiut, int nbEle);
void modifChefDept(VilleIUT **tiut, int nbEle);
void triEchange(VilleIUT **tiut, int nbEle);
int plusGrand(VilleIUT **tiut, int nbEle);
void echanger(VilleIUT **tiut, int i, int j);
void clearpage(void); void clearpage(void);
ListeDept creerListeDept(void);
VilleIUT **chargementVille(char *nomFich, int tphys, int *tailleL);
VilleIUT lireVille(FILE *flot);
ListeDept traiterDept(ListeDept l, FILE *flot);
ListeDept ajouterEnTeteDept(ListeDept l, char *dept, char *nom, int nbP);
void affichageListeDept(ListeDept l);
ListeDept insererDept(ListeDept l, char *dept, char *nom, int nbP);
ListeDept supprimerEnTêteDept(ListeDept l);
ListeDept supprimerDept(ListeDept l, char *code);
bool vide(ListeDept l);
ListeDept rechercheDept(ListeDept l, char code[]);

@ -1,4 +1,4 @@
#include "SAEl.h" #include "SAE.h"
ListeDept creerListeDept(void) ListeDept creerListeDept(void)
{ {
@ -79,7 +79,7 @@ ListeDept traiterDept(ListeDept l, FILE *flot)
return l; return l;
} }
ListeDept ajouterEnTete(ListeDept l, char *dept, char *nom, int nbP) ListeDept ajouterEnTeteDept(ListeDept l, char *dept, char *nom, int nbP)
{ {
MaillonDept *nouv; MaillonDept *nouv;
nouv = (MaillonDept *)malloc(sizeof(MaillonDept)); nouv = (MaillonDept *)malloc(sizeof(MaillonDept));
@ -99,12 +99,12 @@ void affichageListeDept(ListeDept l) // itératif
{ {
while (l != NULL) while (l != NULL)
{ {
printf("%s\t%d\t%s\n", l->departement, l->nbPlaces, l->nom); printf("- %s :\n|%d places\t%s\n\t", l->departement, l->nbPlaces, l->nom);
l = l->suiv; l = l->suiv;
} }
} }
ListeDept inserer(ListeDept l, char *dept, char *nom, int nbP) ListeDept insererDept(ListeDept l, char *dept, char *nom, int nbP)
{ // récursif { // récursif
if (l == NULL) if (l == NULL)
return ajouterEnTete(l, dept, nom, nbP); return ajouterEnTete(l, dept, nom, nbP);
@ -116,7 +116,7 @@ ListeDept inserer(ListeDept l, char *dept, char *nom, int nbP)
return l; return l;
} }
ListeDept supprimerEnTête(ListeDept l) ListeDept supprimerEnTêteDept(ListeDept l)
{ {
MaillonDept *aux; MaillonDept *aux;
if (l == NULL) if (l == NULL)
@ -132,14 +132,14 @@ ListeDept supprimerEnTête(ListeDept l)
return l; return l;
} }
ListeDept supprimer(ListeDept l, char *code) ListeDept supprimerDept(ListeDept l, char *code)
{ {
if (l == NULL) if (l == NULL)
return l; return l;
if ((strcmp(code,l->departement)) < 0) if ((strcmp(code,l->departement)) < 0)
return l; return l;
if ((strcmp(code,l->departement)) == 0) if ((strcmp(code,l->departement)) == 0)
return supprimerEnTête(l); return supprimerEnTêteDept(l);
l->suiv = supprimer(l->suiv, code); l->suiv = supprimer(l->suiv, code);
return l; return l;
} }
@ -183,15 +183,15 @@ int longueur(ListeDept l)
} }
*/ */
bool rechercheDept(ListeDept l, char code[]) ListeDept rechercheDept(ListeDept l, char code[])
{ {
if (l == NULL) if (l == NULL)
return false; return NULL;
if ((strcmp(code,l->departement)) < 0) if ((strcmp(code,l->departement)) < 0)
return false; return NULL;
if (strcmp(code,l->departement)==0) if (strcmp(code,l->departement)==0)
return true; return l->departement;
return recherche(l->suiv, x); return rechercheDept(l->suiv, code);
} }
/* /*

Loading…
Cancel
Save