|
|
@ -1,12 +1,125 @@
|
|
|
|
#include "Msae.h"
|
|
|
|
#include "Msae.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//################ fonctions listes ###################################
|
|
|
|
|
|
|
|
ListeDept listeDeptNouv(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ListeDept lDept;
|
|
|
|
|
|
|
|
lDept = NULL;
|
|
|
|
|
|
|
|
return lDept;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ListeDept insererEntete(ListeDept lDept,Departement d)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MaillonDept *m;
|
|
|
|
|
|
|
|
m = (MaillonDept *)malloc(sizeof(MaillonDept));
|
|
|
|
|
|
|
|
if(m == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Problème d'allocation mémoire lors de l'insertion\n");
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
m->d = d;
|
|
|
|
|
|
|
|
m->suiv = lDept;
|
|
|
|
|
|
|
|
return m;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ListeDept supprimerEntete(ListeDept lDept)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ListeDept aux;
|
|
|
|
|
|
|
|
if(lDept == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Opération interdite\n");
|
|
|
|
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
aux = lDept;
|
|
|
|
|
|
|
|
lDept = lDept->suiv;
|
|
|
|
|
|
|
|
free(aux);
|
|
|
|
|
|
|
|
return lDept;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ListeDept supprimerDept(ListeDept lDept, Departement d)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(lDept == NULL)
|
|
|
|
|
|
|
|
return lDept;
|
|
|
|
|
|
|
|
if(strcmp(d.dept, lDept->d.dept) < 0)
|
|
|
|
|
|
|
|
return lDept;
|
|
|
|
|
|
|
|
if(strcmp(d.dept,lDept->d.dept) == 0)
|
|
|
|
|
|
|
|
return supprimerEntete(lDept);
|
|
|
|
|
|
|
|
lDept->suiv = supprimerDept(lDept->suiv,d);
|
|
|
|
|
|
|
|
return lDept;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int longueur(ListeDept lDept)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int compt = 0;
|
|
|
|
|
|
|
|
while(lDept != NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
compt = compt + 1;
|
|
|
|
|
|
|
|
lDept = lDept->suiv;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return compt;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool vide(ListeDept lDept)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(lDept == NULL)
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//################ fonction commune ###################################
|
|
|
|
//################ fonction commune ###################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Departement lireDep(FILE *flot)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Departement d;
|
|
|
|
|
|
|
|
fscanf(flot,"%s%d", d.dept, &d.nbP);
|
|
|
|
|
|
|
|
fgets(d.respAd,31,flot);
|
|
|
|
|
|
|
|
d.respAd[strlen(d.respAd) - 1] = '\0';
|
|
|
|
|
|
|
|
return d;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int chargement(VilleIUT *tiut[],int tMax)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
FILE *flot;
|
|
|
|
|
|
|
|
int tLog = 0, pos, trouve;
|
|
|
|
|
|
|
|
char nomV[31];
|
|
|
|
|
|
|
|
Departement d;
|
|
|
|
|
|
|
|
flot = fopen("IUT.don","r");
|
|
|
|
|
|
|
|
if(flot == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Erreur lors de l'ouverture du fichier\n");
|
|
|
|
|
|
|
|
fclose(flot);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fscanf(flot, "%s", nomV);
|
|
|
|
|
|
|
|
while(!feof(flot))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(tLog == tMax)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Tableau tiut plein\n");
|
|
|
|
|
|
|
|
fclose(flot);
|
|
|
|
|
|
|
|
return -3;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
d = lireDep(flot);
|
|
|
|
|
|
|
|
pos = rechercheIUT(tiut,tLog,nomV,&trouve);
|
|
|
|
|
|
|
|
if(trouve == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
tiut[pos]->lDept = insererDept(tiut[pos]->lDept, d);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
insererVille(tiut, nomV, d, &tLog, tMax, pos);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fscanf(flot, "%s", nomV);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(flot);
|
|
|
|
|
|
|
|
return tLog;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void clearpage(void)
|
|
|
|
void clearpage(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char entre;
|
|
|
|
char entre;
|
|
|
|
printf("\nappuyé sur la touche [ENTREE] pour continuer");
|
|
|
|
printf("\nappuyé sur la touche [ENTREE] pour continuer");
|
|
|
|
scanf("%*c%c", &entre);
|
|
|
|
scanf("%c", &entre);
|
|
|
|
system("clear");
|
|
|
|
system("clear");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -56,6 +169,26 @@ int login(void)
|
|
|
|
|
|
|
|
|
|
|
|
//################# fonctions affichage ###########################
|
|
|
|
//################# fonctions affichage ###########################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void afficherTIUT(VilleIUT *tiut[], int tLog)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
printf("____________________________________\n");
|
|
|
|
|
|
|
|
printf("| Ville |\n");
|
|
|
|
|
|
|
|
for(i = 0; i < tLog; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
afficherVille(*tiut[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
clearpage();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void afficherVille(VilleIUT v)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("|----------------------------------|\n");
|
|
|
|
|
|
|
|
printf("| %-32s |\n", v.nom);
|
|
|
|
|
|
|
|
printf("|----------------------------------|\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void afficherPlace(Departement d)
|
|
|
|
void afficherPlace(Departement d)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("\nPour ce département il y a %d places en 1ère année \n\n",d.nbP);
|
|
|
|
printf("\nPour ce département il y a %d places en 1ère année \n\n",d.nbP);
|
|
|
@ -85,15 +218,6 @@ void afficherDep(Departement d)
|
|
|
|
printf("|----------------------------------------------------------------------------|\n");
|
|
|
|
printf("|----------------------------------------------------------------------------|\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//################ fonction liste ######################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool vide(ListeDept lDept)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(lDept == NULL)
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//################# fonctions recherche #########################
|
|
|
|
//################# fonctions recherche #########################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -139,6 +263,43 @@ ListeDept rechercherDept(ListeDept lDept, char dept[], int *trouve)
|
|
|
|
return rechercherDept(lDept->suiv, dept, trouve);
|
|
|
|
return rechercherDept(lDept->suiv, dept, trouve);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//#################### fonctions d'insertion ###########################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ListeDept insererDept(ListeDept lDept, Departement d)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(lDept == NULL)
|
|
|
|
|
|
|
|
return insererEntete(lDept,d);
|
|
|
|
|
|
|
|
if(strcmp(d.dept, lDept->d.dept) < 0)
|
|
|
|
|
|
|
|
return insererEntete(lDept,d);
|
|
|
|
|
|
|
|
if(strcmp(d.dept,lDept->d.dept) == 0)
|
|
|
|
|
|
|
|
printf("Département déjà présent dans cet IUT\n");
|
|
|
|
|
|
|
|
return lDept;
|
|
|
|
|
|
|
|
lDept->suiv = insererDept(lDept->suiv,d);
|
|
|
|
|
|
|
|
return lDept;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int insererVille(VilleIUT *tiut[], char nomV[], Departement d, int *tLog, int tMax, int pos)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if(*tLog == tMax)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Tableau plein, insertion impossible\n");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = *tLog - 1; i >= pos; i--)
|
|
|
|
|
|
|
|
tiut[i + 1] = tiut[i];
|
|
|
|
|
|
|
|
tiut[pos] = (VilleIUT *)malloc(sizeof(VilleIUT));
|
|
|
|
|
|
|
|
if(tiut[pos] == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("problème d'allocation mémoire lors de l'insertion de la ville\n");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(tiut[pos]->nom, nomV);
|
|
|
|
|
|
|
|
tiut[pos]->lDept = listeDeptNouv();
|
|
|
|
|
|
|
|
tiut[pos]->lDept = insererDept(tiut[pos]->lDept,d);
|
|
|
|
|
|
|
|
*tLog = *tLog + 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//#################### fonction mise à jour ############################
|
|
|
|
//#################### fonction mise à jour ############################
|
|
|
|
|
|
|
|
|
|
|
@ -209,8 +370,9 @@ void miseAJourGlobale(VilleIUT *tiut[], int tLog)
|
|
|
|
char ville[31],dept[31];
|
|
|
|
char ville[31],dept[31];
|
|
|
|
MaillonDept *m;
|
|
|
|
MaillonDept *m;
|
|
|
|
Departement d;
|
|
|
|
Departement d;
|
|
|
|
|
|
|
|
system("clear");
|
|
|
|
printf("Dans quelle ville voulez-vous faire des mises à jour?\t");
|
|
|
|
printf("Dans quelle ville voulez-vous faire des mises à jour?\t");
|
|
|
|
scanf("%s%*c",ville);
|
|
|
|
scanf("%s",ville);
|
|
|
|
pos=rechercheIUT(tiut,tLog,ville,&trouve);
|
|
|
|
pos=rechercheIUT(tiut,tLog,ville,&trouve);
|
|
|
|
if(trouve!=1)
|
|
|
|
if(trouve!=1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|