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

211
SAE.c

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

79
SAE.h

@ -12,7 +12,7 @@ typedef struct maillon
struct maillon *suiv;
}MaillonDept;
typedef MaillonDept* Liste;
typedef MaillonDept* ListeDept;
typedef struct
{
@ -20,6 +20,25 @@ typedef struct
MaillonDept *idDept;
}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 verifQuit(void);
@ -28,8 +47,62 @@ int menuUtilisateurAffiche(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);
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)
{
@ -79,7 +79,7 @@ ListeDept traiterDept(ListeDept l, FILE *flot)
return l;
}
ListeDept ajouterEnTete(ListeDept l, char *dept, char *nom, int nbP)
ListeDept ajouterEnTeteDept(ListeDept l, char *dept, char *nom, int nbP)
{
MaillonDept *nouv;
nouv = (MaillonDept *)malloc(sizeof(MaillonDept));
@ -99,12 +99,12 @@ void affichageListeDept(ListeDept l) // itératif
{
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;
}
}
ListeDept inserer(ListeDept l, char *dept, char *nom, int nbP)
ListeDept insererDept(ListeDept l, char *dept, char *nom, int nbP)
{ // récursif
if (l == NULL)
return ajouterEnTete(l, dept, nom, nbP);
@ -116,7 +116,7 @@ ListeDept inserer(ListeDept l, char *dept, char *nom, int nbP)
return l;
}
ListeDept supprimerEnTête(ListeDept l)
ListeDept supprimerEnTêteDept(ListeDept l)
{
MaillonDept *aux;
if (l == NULL)
@ -132,14 +132,14 @@ ListeDept supprimerEnTête(ListeDept l)
return l;
}
ListeDept supprimer(ListeDept l, char *code)
ListeDept supprimerDept(ListeDept l, char *code)
{
if (l == NULL)
return l;
if ((strcmp(code,l->departement)) < 0)
return l;
if ((strcmp(code,l->departement)) == 0)
return supprimerEnTête(l);
return supprimerEnTêteDept(l);
l->suiv = supprimer(l->suiv, code);
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)
return false;
return NULL;
if ((strcmp(code,l->departement)) < 0)
return false;
return NULL;
if (strcmp(code,l->departement)==0)
return true;
return recherche(l->suiv, x);
return l->departement;
return rechercheDept(l->suiv, code);
}
/*

Loading…
Cancel
Save