|
|
|
@ -98,7 +98,7 @@ void affichageListeDept(ListeDept l) // itératif
|
|
|
|
|
{
|
|
|
|
|
while (l != NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("- %s :\n|%d places\t%s\n\t", l->departement, l->nbPlaces, l->nom);
|
|
|
|
|
printf("- %s :\t|%d places\t\t%s|\n", l->departement, l->nbPlaces, l->nom);
|
|
|
|
|
l = l->suiv;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -169,102 +169,18 @@ bool vide(ListeDept l)
|
|
|
|
|
return true; // 1
|
|
|
|
|
return false; // 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int longueurListe(ListeDept l)
|
|
|
|
|
/*
|
|
|
|
|
int longueur(ListeDept l)
|
|
|
|
|
{
|
|
|
|
|
int cpt = 0;
|
|
|
|
|
while (l != NULL)
|
|
|
|
|
{
|
|
|
|
|
cpt += 1;
|
|
|
|
|
cpt + 1;
|
|
|
|
|
l = l->suiv;
|
|
|
|
|
}
|
|
|
|
|
return cpt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SauvegarderIUT(VilleIUT** tabV, int tailleL) {
|
|
|
|
|
int i;
|
|
|
|
|
FILE* flot;
|
|
|
|
|
flot = fopen("iut.txt","w");
|
|
|
|
|
for (i = 0 ; i < tailleL ; i++) {
|
|
|
|
|
fprintf(flot,"%s\n",tabV[i]->ville);
|
|
|
|
|
fprintf(flot,"%d\n",longueurListe(tabV[i]->idDept));
|
|
|
|
|
SauvegarderListe(tabV[i]->idDept,flot);
|
|
|
|
|
free(tabV[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SauvegarderListe(ListeDept l, FILE* flot) {
|
|
|
|
|
MaillonDept* tmp;
|
|
|
|
|
while (l->suiv != NULL) {
|
|
|
|
|
tmp = l;
|
|
|
|
|
fprintf(flot,"%s %d %s\n",l->departement,l->nbPlaces,l->nom);
|
|
|
|
|
l = l->suiv;
|
|
|
|
|
free(tmp);
|
|
|
|
|
}
|
|
|
|
|
fprintf(flot,"%s %d %s\n",l->departement,l->nbPlaces,l->nom);
|
|
|
|
|
free(l);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void creationDept(VilleIUT **tiut, int nbEle)
|
|
|
|
|
{
|
|
|
|
|
MaillonDept *aux;
|
|
|
|
|
char code[30], nom[30];
|
|
|
|
|
int trouve, pos, nbP;
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
printf("Dans quel IUT voulez-vous créer un département : ");
|
|
|
|
|
scanf("%s", code);
|
|
|
|
|
pos = rechVille(tiut, nbEle, code, &trouve);
|
|
|
|
|
if (trouve == 1)
|
|
|
|
|
{
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
printf("Nom du Département : ");
|
|
|
|
|
scanf("%s", code);
|
|
|
|
|
aux = rechercheDept(tiut[pos]->idDept, code);
|
|
|
|
|
if (aux != NULL)
|
|
|
|
|
printf("Département déjà existant");
|
|
|
|
|
if (aux == NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("Nom du Responsable du Département de %s : ",code);
|
|
|
|
|
fgets(nom,30,stdin);
|
|
|
|
|
nom[strlen(nom)-1] = '\0';
|
|
|
|
|
printf("Nombre de place du Département %s : ",code);
|
|
|
|
|
scanf("%d", nbP);
|
|
|
|
|
tiut[pos]->idDept = insererDept(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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool verifSelection(void)
|
|
|
|
|
{
|
|
|
|
|
char choix[4];
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
printf("Voulez-vous continué la sélection (oui|non) : ");
|
|
|
|
|
scanf("%s",choix);
|
|
|
|
|
if (strcmp(choix,"oui")==0)
|
|
|
|
|
return true;
|
|
|
|
|
if (strcmp(choix,"non")==0)
|
|
|
|
|
return false;
|
|
|
|
|
printf("Erreur de sélection ! Veuillez réessayer \n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
ListeDept rechercheDept(ListeDept l, char code[])
|
|
|
|
|
{
|
|
|
|
@ -277,23 +193,6 @@ ListeDept rechercheDept(ListeDept l, char code[])
|
|
|
|
|
return rechercheDept(l->suiv, code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int rechVille(VilleIUT **tiut, int nbEle, char code[], int *trouve)
|
|
|
|
|
{
|
|
|
|
|
int inf = 0, sup = nbEle - 1, m;
|
|
|
|
|
while(inf <= sup)
|
|
|
|
|
{
|
|
|
|
|
m = (inf + sup)/2;
|
|
|
|
|
if (strcmp(tiut[m]->ville, code)==0)
|
|
|
|
|
{
|
|
|
|
|
*trouve = 1;
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(tiut[m]->ville, code)>0)
|
|
|
|
|
sup = m - 1;
|
|
|
|
|
else inf = m + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ListeDept ajouterEnQueue(ListeDept l, int x)
|
|
|
|
|
{
|
|
|
|
|