|
|
@ -5,7 +5,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
void lireM(FILE *f, MaillonDept * m)//lire maillon
|
|
|
|
void lireM(FILE *f, MaillonDept * m)//lire maillon
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fscanf(f, "%s %d %s", m->departement, &m->nbP, m->respAd);
|
|
|
|
fscanf(f, "%s %d", m->departement, &m->nbP);
|
|
|
|
|
|
|
|
fgets(m->respAd, 31, f);
|
|
|
|
|
|
|
|
m->respAd[strlen(m->respAd)-1]='\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -33,7 +35,7 @@ ListDept InsertT(ListDept list, MaillonDept * m)//Insert en tête de la liste
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ListDept Insert(ListDept list, MaillonDept *m)
|
|
|
|
ListDept Insert(ListDept list, MaillonDept *m)//insert globalement
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (list == NULL){return InsertT(list, m);}
|
|
|
|
if (list == NULL){return InsertT(list, m);}
|
|
|
|
if (strcmp(list->departement, m->departement)>0){return InsertT(list, m);}
|
|
|
|
if (strcmp(list->departement, m->departement)>0){return InsertT(list, m);}
|
|
|
@ -41,6 +43,7 @@ ListDept Insert(ListDept list, MaillonDept *m)
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*étapes pour le chargement:
|
|
|
|
/*étapes pour le chargement:
|
|
|
|
1) pour chaque ville : malloc VilleIUT ->initialisation à NULL de la liste et fscanf la ville
|
|
|
|
1) pour chaque ville : malloc VilleIUT ->initialisation à NULL de la liste et fscanf la ville
|
|
|
|
2) récup le nb pour faire une boucle
|
|
|
|
2) récup le nb pour faire une boucle
|
|
|
@ -50,11 +53,56 @@ et on recommence tant que fichier non vide*/
|
|
|
|
int Chargement(VilleIUT **tV, int tmax, char *nameFile)
|
|
|
|
int Chargement(VilleIUT **tV, int tmax, char *nameFile)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
FILE *f;
|
|
|
|
int cpt, cptbcl;
|
|
|
|
int i = 0;
|
|
|
|
f = fopen(nameFile, "r");
|
|
|
|
f = fopen(nameFile, "r");
|
|
|
|
if (f == NULL){printf("pb ouv file"); return -1;}
|
|
|
|
if (f == NULL){printf("pb ouv file"); return -1;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (!feof(f))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int cpt;
|
|
|
|
|
|
|
|
VilleIUT *v;
|
|
|
|
|
|
|
|
v = (VilleIUT *)malloc(sizeof(VilleIUT));
|
|
|
|
|
|
|
|
if (v == NULL){printf("pb malloc");exit;}
|
|
|
|
|
|
|
|
fscanf(f, "%s %d", v->ville, &cpt);
|
|
|
|
|
|
|
|
printf("**%d**\n", cpt);
|
|
|
|
|
|
|
|
for (cpt; cpt > 0; cpt--)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("bleu\n");
|
|
|
|
|
|
|
|
MaillonDept *m;
|
|
|
|
|
|
|
|
m = (MaillonDept*)malloc(sizeof(MaillonDept));
|
|
|
|
|
|
|
|
if (m == NULL){printf("pb malloc"); exit;}
|
|
|
|
|
|
|
|
lireM(f, m);
|
|
|
|
|
|
|
|
AfficheDpmt(m);
|
|
|
|
|
|
|
|
v->ldept = Insert(v->ldept, m);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tV[i] = v;
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AfficheDpmt ( MaillonDept *dpt ){
|
|
|
|
|
|
|
|
if ( dpt == NULL) return;
|
|
|
|
|
|
|
|
printf("%s %d %s \n", dpt->departement, dpt->nbP, dpt->respAd);
|
|
|
|
|
|
|
|
AfficheDpmt(dpt->suiv);}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void afficheIUT (VilleIUT *iut){
|
|
|
|
|
|
|
|
printf ("%s \n", iut->ville);
|
|
|
|
|
|
|
|
AfficheDpmt(iut->ldept);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Affichetableau(VilleIUT ** TabIUT, int n ){
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( i = 0 ; i < n ; i++ )
|
|
|
|
|
|
|
|
afficheIUT(TabIUT[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|