diff --git a/adminIut.c b/adminIut.c index 1efa1be..1bfd032 100644 --- a/adminIut.c +++ b/adminIut.c @@ -2,11 +2,12 @@ #include #include #include "iut.h" -/* -void MenuAdministrateur(VilleIUT V){ + +void MenuAdministrateur(VilleIUT *tiut[],int n){ char departement[30],respon[30]; int choix,nbp; - Maillon m; + VilleIUT V; + printf("\n1-Modifier place\n2-Creer un departement\n3-supprimer un département\n4-Lancer et Arreter la phase de canditature\n5-modifier nom responsable"); scanf("%d",&choix); if(choix==1){ @@ -20,7 +21,7 @@ void MenuAdministrateur(VilleIUT V){ scanf("%d",&nbp); printf("\nresponsable :"); scanf("%s",respon); - V=Enfiler(V,departement,nbp,respon); + //V=Enfiler(V,departement,nbp,respon); } if(choix==3){ //supprimer departement et pauser condition pour choisir qui suppr @@ -29,8 +30,8 @@ void MenuAdministrateur(VilleIUT V){ printf("\nresponsable :"); scanf("%s",respon); // *resultat=recherche(V.Ville,departement,respon); - m=suppression(m,departement,respon); - afficherE(m); + //m=suppression(m,departement,respon); + affichage(tiut, n); } if(choix==4){ //Lancer et arreter phase de canditature @@ -38,31 +39,58 @@ void MenuAdministrateur(VilleIUT V){ if(choix==5){ //modification responsable } - afficher(V); + } -Maillon suppressionTete(Maillon m){ - Maillon svt; - svt=m->suivant; - free(m); - return svt; +ListeD suppressionTete(ListeD ld){ + ListeD ldsvt; + ldsvt=ld->suivant; + free(ld); + return ldsvt; } -Maillon suppression(Maillon m,char *departement,char *responsable){ - if(m==NULL) - return m; - if(strcmp(m->departement,departement) ==0 && strcmp(m->resp,responsable) ==0) - return suppressionTete(m); - m->suivant=suppression(m->suivant,departement,responsable); - return m; +ListeD suppression(ListeD ld,char *departement,char *responsable){ + if(ld==NULL) + return ld; + if(strcmp(ld->departement,departement) ==0 && strcmp(ld->resp,responsable) ==0) + return suppressionTete(ld); + ld->suivant=suppression(ld->suivant,departement,responsable); + return ld; } -void afficherE(Maillon m){ - if(m==NULL)return; - printf("\n%s\t",m->departement); - printf("%d\t",m->nbP); - printf("%s\t",m->resp); - afficherE(m->suivant); + +/* +VilleIUT Enfiler(VilleIUT V, char *departement, int nbP,char *resp){ + MaillonDept *m; + m=(MaillonDept*)malloc(sizeof(MaillonDept)); + if(m==NULL){printf("pb ouv malloc");exit(1);} + strcpy(m->departement, departement); + m->nbP=nbP; + strcpy(m->resp,resp); + m->suivant=NULL; + if(testVide(V)){ + V.Ville=m; + V.Idept=m; + } + else{ + V.Idept->suivant=m; + V.Idept=m; + } + return V; } + +VilleIUT defiler(VilleIUT V){ + MaillonDept *temp; + if(testVide(V)){ + printf("testVide"); + return V; + } + temp=V.Ville; + V.Ville=temp->suivant; + free(temp); + if(V.Ville==NULL) + V.Idept=NULL; + return V; +} */ \ No newline at end of file diff --git a/iut.c b/iut.c index a0f4240..7c9783a 100644 --- a/iut.c +++ b/iut.c @@ -80,68 +80,10 @@ ListeD Insertion(ListeD ld, char *departement, int nbP,char *resp){ ld->suivant = Insertion(ld->suivant, departement, nbP, resp); return ld; } -/*VilleIUT Enfiler(VilleIUT V, char *departement, int nbP,char *resp){ - MaillonDept *m; - m=(MaillonDept*)malloc(sizeof(MaillonDept)); - if(m==NULL){printf("pb ouv malloc");exit(1);} - strcpy(m->departement, departement); - m->nbP=nbP; - strcpy(m->resp,resp); - m->suivant=NULL; - if(testVide(V)){ - V.Ville=m; - V.Idept=m; - } - else{ - V.Idept->suivant=m; - V.Idept=m; - } - return V; -} - - -VilleIUT defiler(VilleIUT V){ - MaillonDept *temp; - if(testVide(V)){ - printf("testVide"); - return V; - } - temp=V.Ville; - V.Ville=temp->suivant; - free(temp); - if(V.Ville==NULL) - V.Idept=NULL; - return V; -} - -void afficher (VilleIUT V){ - if(testVide(V)) - return; - printf("\n%s\t",V.Ville->departement); - printf("%d\t",V.Ville->nbP); - printf("%s\t",V.Ville->resp); - V.Ville=V.Ville->suivant; - afficher(V); -} - - - -VilleIUT lireVille(FILE *fe, int *nbDep){ - VilleIUT V; - fscanf(fe,"%s %d", V.ville, nbDep); - return V; -} - -MaillonDept lireDep(FILE *fe){ - MaillonDept m; - fscanf(fe,"%s %d %s", m.departement, m.nbP, m.resp); - return m; -}*/ - void affichage (VilleIUT *tiut[],int n){ int i; for(i=0;i