|
|
|
@ -4,11 +4,7 @@
|
|
|
|
|
#include "iut.h"
|
|
|
|
|
|
|
|
|
|
//Fonction d'initialisation de VilleIUT --> Renvoie une liste vide
|
|
|
|
|
VilleIUT Initialisation(void){
|
|
|
|
|
VilleIUT V;
|
|
|
|
|
V.ldept = NULL;
|
|
|
|
|
return V;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Fonction qui teste si la liste est vide ou non, et renvoie 'Vrai si la liste est vide', sinon 'Faux'
|
|
|
|
|
Booleen testVide(VilleIUT V){
|
|
|
|
@ -22,7 +18,7 @@ int chargement(VilleIUT *tiut[],int tmax){
|
|
|
|
|
int i = 0, j=0;
|
|
|
|
|
int nbDep = 0;
|
|
|
|
|
VilleIUT V;
|
|
|
|
|
MaillonDept *m;
|
|
|
|
|
MaillonDept m;
|
|
|
|
|
FILE *fe;
|
|
|
|
|
fe=fopen("ville.don","r");
|
|
|
|
|
if(fe==NULL){
|
|
|
|
@ -37,11 +33,11 @@ int chargement(VilleIUT *tiut[],int tmax){
|
|
|
|
|
printf("Problème de malloc");
|
|
|
|
|
return -3;
|
|
|
|
|
}
|
|
|
|
|
*tiut[i] = Initialisation();
|
|
|
|
|
*tiut[i] = V;
|
|
|
|
|
for(j = 0; j < nbDep; j++){
|
|
|
|
|
*m = lireDep(fe);
|
|
|
|
|
tiut[i] = Insertion(m,m->departement, m->nbP, m->resp);
|
|
|
|
|
|
|
|
|
|
m = lireDep(fe);
|
|
|
|
|
tiut[i]->ldept = Insertion(tiut[i]->ldept, m.departement, m.nbP, m.resp);
|
|
|
|
|
}
|
|
|
|
|
V = lireVille(fe, &nbDep);
|
|
|
|
|
i++;
|
|
|
|
@ -52,6 +48,7 @@ int chargement(VilleIUT *tiut[],int tmax){
|
|
|
|
|
|
|
|
|
|
VilleIUT lireVille(FILE *fe, int *nbDep){
|
|
|
|
|
VilleIUT V;
|
|
|
|
|
V.ldept = NULL;
|
|
|
|
|
fscanf(fe,"%s %d", V.ville, nbDep);
|
|
|
|
|
return V;
|
|
|
|
|
}
|
|
|
|
@ -62,7 +59,8 @@ MaillonDept lireDep(FILE *fe){
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaillonDept InsertionTete(MaillonDept *m, char *departement, int nbP,char *resp){
|
|
|
|
|
ListeD InsertionTete(ListeD ld, char *departement, int nbP,char *resp){
|
|
|
|
|
MaillonDept *m;
|
|
|
|
|
m = (MaillonDept*)malloc(sizeof(MaillonDept));
|
|
|
|
|
if(m==NULL){
|
|
|
|
|
printf("Problème malloc m");
|
|
|
|
@ -70,16 +68,17 @@ MaillonDept InsertionTete(MaillonDept *m, char *departement, int nbP,char *resp)
|
|
|
|
|
strcpy(m->departement, departement);
|
|
|
|
|
m->nbP = nbP;
|
|
|
|
|
strcpy(m->resp, resp);
|
|
|
|
|
return *m;
|
|
|
|
|
m->suivant = ld;
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaillonDept Insertion(MaillonDept *m, char *departement, int nbP,char *resp){
|
|
|
|
|
if(m==NULL)
|
|
|
|
|
return InsertionTete(m, departement, nbP, resp);
|
|
|
|
|
if(strcmp(m->departement, departement)<0)
|
|
|
|
|
return InsertionTete(m, departement, nbP, resp);
|
|
|
|
|
m->suivant = Insertion(m->suivant, departement, nbP, resp);
|
|
|
|
|
return *m;
|
|
|
|
|
ListeD Insertion(ListeD ld, char *departement, int nbP,char *resp){
|
|
|
|
|
if(ld==NULL)
|
|
|
|
|
return InsertionTete(ld, departement, nbP, resp);
|
|
|
|
|
if(strcmp(ld->departement, departement)<0)
|
|
|
|
|
return InsertionTete(ld, departement, nbP, resp);
|
|
|
|
|
ld->suivant = Insertion(ld->suivant, departement, nbP, resp);
|
|
|
|
|
return ld;
|
|
|
|
|
}
|
|
|
|
|
/*VilleIUT Enfiler(VilleIUT V, char *departement, int nbP,char *resp){
|
|
|
|
|
MaillonDept *m;
|
|
|
|
@ -141,13 +140,20 @@ MaillonDept lireDep(FILE *fe){
|
|
|
|
|
MaillonDept m;
|
|
|
|
|
fscanf(fe,"%s %d %s", m.departement, m.nbP, m.resp);
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
void affichage (int *tiut[],int n){
|
|
|
|
|
void affichage (VilleIUT *tiut[],int n){
|
|
|
|
|
int i;
|
|
|
|
|
for(i=0;i<n;i++){
|
|
|
|
|
printf("aaa\n");
|
|
|
|
|
//ici error
|
|
|
|
|
printf("%s %s %d %s", tiut[i]->ville, tiut[i]->Ville->departement, tiut[i]->Ville->nbP, tiut[i]->Ville->resp);
|
|
|
|
|
printf("\n%s\n", tiut[i]->ville);
|
|
|
|
|
affichageListe(tiut[i]->ldept);
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void affichageListe(ListeD ld){
|
|
|
|
|
while(ld!=NULL){
|
|
|
|
|
printf("%s\t",ld->departement);
|
|
|
|
|
printf("%d\t",ld->nbP);
|
|
|
|
|
printf("%s\n",ld->resp);
|
|
|
|
|
ld = ld->suivant;}
|
|
|
|
|
}
|
|
|
|
|