diff --git a/adminIut.c b/adminIut.c index e69de29..5dd2365 100644 --- a/adminIut.c +++ b/adminIut.c @@ -0,0 +1,50 @@ +#include +#include +#include +#include "iut.h" + +void MenuAdministrateur(VilleIUT V){ + char departement[30],respon[30]; + int choix,nbp; + MaillonDept *resultat; + 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){ + //modification nbP + } + if(choix==2){ + //creer departemement + printf("\ndepartement :"); + scanf("%s",departement); + printf("\nnombre de place :"); + scanf("%d",&nbp); + printf("\nresponsable :"); + scanf("%s",respon); + V=Enfiler(V,departement,nbp,respon); + } + if(choix==3){ + //supprimer departement et pauser condition pour choisir qui suppr + printf("\ndepartement :"); + scanf("%s",departement); + printf("\nresponsable :"); + scanf("%s",respon); + // *resultat=recherche(V.Ville,departement,respon); + V=defiler(V); + } + if(choix==4){ + //Lancer et arreter phase de canditature + } + if(choix==5){ + //modification responsable + } +} + +//recherche +/* + MaillonDept recherche (MaillonDept *Ville,char *departement,char *responsable){ + if(Ville==NULL)return NULL; + if(strcmp(Ville->departement,departement) ==0 && strcmp(Ville->resp,responsable) ==0)return Ville; + return recherche(Ville->suivant,departement,responsable); + }*/ + +//------------------------------------------------------------------------------ diff --git a/iut.c b/iut.c new file mode 100644 index 0000000..1f23367 --- /dev/null +++ b/iut.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include "iut.h" + +//Liste: +VilleIUT initialiser (void){ + VilleIUT V; + V.Idept=NULL; + V.Ville=NULL; + return V; +} + +Booleen testVide(VilleIUT V){ + if(V.Ville==NULL) return vrai; + return faux; +} +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); +} diff --git a/iut.h b/iut.h index e69de29..99b62ea 100644 --- a/iut.h +++ b/iut.h @@ -0,0 +1,32 @@ +typedef struct liste{ + char departement[30]; + int nbP; + char resp[30]; + struct liste *suivant; +}MaillonDept; + +typedef struct{ + char ville[30]; + MaillonDept *Ville; + MaillonDept *Idept; +}VilleIUT; + +//VilleIUT *tiut; + +typedef enum {faux,vrai}Booleen; + +//Menu utilisateur : + //void MenuUtilisateur(fdhsjklfhdsjklfhdjskl); + +//Menu administrateur : + void MenuAdministrateur(VilleIUT V); + + //recherche + //MaillonDept recherche (MaillonDept *Ville,char *departement,char *responsable); + +//Liste: + VilleIUT initialiser (void); + VilleIUT Enfiler(VilleIUT V, char *departement, int nbP,char *resp); + Booleen testVide(VilleIUT V); + void afficher (VilleIUT V); + VilleIUT defiler(VilleIUT V); diff --git a/testIut.c b/testIut.c index e69de29..259de4a 100644 --- a/testIut.c +++ b/testIut.c @@ -0,0 +1,30 @@ +#include +#include "iut.h" + +VilleIUT Chargement(VilleIUT V){ + V=initialiser(); + V=Enfiler(V,"Informatique",112,"Dupont Jean"); + V=Enfiler(V,"Informatique",136,"Simon Carine"); + V=Enfiler(V,"Bio-Info",56,"jiji"); + V=Enfiler(V,"Biologie",120,"Djojo"); + return V; +} + + +int main(){ + VilleIUT V; + V = Chargement(V); + afficher(V); + + int choix; + printf("\n\nUtilisateur - 1\tAdministrateur - 2\n\n"); + scanf("%d",&choix); + if(choix==1){ + printf("Menu Utilisateur"); + //MenuUtilisateur(); + } + if(choix==2){ + printf("Menu Administrateur"); + MenuAdministrateur(V); + } +}