master
Lola CHALMIN 2 years ago
parent 3fc893b3e6
commit 36d18e7da8

@ -47,33 +47,30 @@ ListDept Insert(ListDept list, MaillonDept *m)//insert globalement
/*étapes pour le chargement:
1) pour chaque ville : malloc VilleIUT ->initialisation à NULL de la liste et fscanf la ville
2) récup le nb pour faire une boucle
3) boucle dans laquelle on crée nb maillons en insertion du département dans la liste en triant
3) boucle dans laquelle on crée nb maillons en inserant département dans la liste en triant
et on recommence tant que fichier non vide*/
int Chargement(VilleIUT **tV, int tmax, char *nameFile)
{
FILE *f;
int i = 0;
int i = 0, cpt;
f = fopen(nameFile, "r");
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));
m = (MaillonDept*)malloc(sizeof(MaillonDept));//création du maillon
if (m == NULL){printf("pb malloc"); exit;}
lireM(f, m);
AfficheDpmt(m);
v->ldept = Insert(v->ldept, m);
lireM(f, m);//lire le maillon avec la fonction plus haut
v->ldept = Insert(v->ldept, m);//insert le maillon à sa bonne place
}
tV[i] = v;
i++;
@ -84,25 +81,62 @@ int Chargement(VilleIUT **tV, int tmax, char *nameFile)
}
void AfficheDpmt ( MaillonDept *dpt ){
void AfficheDpmt ( MaillonDept *dpt )//Affiche un département d'une liste
{
if ( dpt == NULL) return;
printf("%s %d %s \n", dpt->departement, dpt->nbP, dpt->respAd);
AfficheDpmt(dpt->suiv);}
AfficheDpmt(dpt->suiv);
}
void afficheIUT (VilleIUT *iut){
void afficheIUT (VilleIUT *iut)//Affiche un iut avec ses départements
{
printf ("%s \n", iut->ville);
AfficheDpmt(iut->ldept);
}
void Affichetableau(VilleIUT ** TabIUT, int n ){
void Affichetableau(VilleIUT ** TabIUT, int n )//Affiche le tableau des iuts avec lerus départements
{
int i;
for ( i = 0 ; i < n ; i++ )
afficheIUT(TabIUT[i]);
}
ListDept MaJnbP(VilleIUT **tV, char *ville, char dpt, int newnbP)
{
}

BIN
test

Binary file not shown.

@ -11,6 +11,5 @@ int main(void)
VilleIUT *tV[200];
int nb;
nb = Chargement(tV, 200, "part1.don");
Affichetableau(tV, nb);
return 0;
}

Loading…
Cancel
Save