master
Benjamin BACHELARD 2 years ago
parent 64334dd2a3
commit 62d052f086

@ -6,7 +6,7 @@
void MenuAdministrateur(VilleIUT V){
char departement[30],respon[30];
int choix,nbp;
MaillonDept *resultat;
Maillon m;
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){
@ -29,7 +29,8 @@ void MenuAdministrateur(VilleIUT V){
printf("\nresponsable :");
scanf("%s",respon);
// *resultat=recherche(V.Ville,departement,respon);
V=defiler(V);
m=suppression(m,departement,respon);
afficherE(m);
}
if(choix==4){
//Lancer et arreter phase de canditature
@ -37,14 +38,30 @@ void MenuAdministrateur(VilleIUT V){
if(choix==5){
//modification responsable
}
afficher(V);
}
//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);
}*/
//------------------------------------------------------------------------------
Maillon suppressionTete(Maillon m){
Maillon svt;
svt=m->suivant;
free(m);
return svt;
}
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;
}
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);
}

48
iut.c

@ -56,3 +56,51 @@ void afficher (VilleIUT V){
V.Ville=V.Ville->suivant;
afficher(V);
}
int chargeResultat(VilleIUT *tiut[],int taillemax){
int i=0,m;
FILE *fe;
fe=fopen("ville.don","r");
if(fe==NULL){printf("pb ouv");return-1;}
VilleIUT V;
V=lireVille(fe);
while(!feof(fe)){
if(i==taillemax){
printf("pb de place");
return -2;
}
tiut[i]=(VilleIUT*)malloc(sizeof(VilleIUT));
if(tiut[i]==NULL){
printf("pb de malloc");
return -3;
}
*tiut[i]=V;
i++;
V=lireVille(fe);
}
fclose(fe);
return i;
}
VilleIUT lireVille (FILE *fe){
VilleIUT V;
fscanf(fe,"%s %s %d %s",&V.ville,&V.Ville->departement,&V.Ville->nbP,&V.Ville->resp);
return V;
}
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);
}
}

15
iut.h

@ -1,9 +1,11 @@
#include <stdio.h>
typedef struct liste{
char departement[30];
int nbP;
char resp[30];
struct liste *suivant;
}MaillonDept;
}MaillonDept,*Maillon;
typedef struct{
char ville[30];
@ -21,6 +23,11 @@ typedef enum {faux,vrai}Booleen;
//Menu administrateur :
void MenuAdministrateur(VilleIUT V);
Maillon suppression(Maillon m,char *departement,char *responsable);
Maillon suppressionTete(Maillon m);
void afficherE(Maillon m);
//recherche
//MaillonDept recherche (MaillonDept *Ville,char *departement,char *responsable);
@ -30,3 +37,9 @@ typedef enum {faux,vrai}Booleen;
Booleen testVide(VilleIUT V);
void afficher (VilleIUT V);
VilleIUT defiler(VilleIUT V);
VilleIUT lireVille (FILE *fe);
int chargeResultat(VilleIUT *tiut[],int taillemax);
void affichage (VilleIUT *tiut[],int n);

@ -3,19 +3,23 @@
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;
int n;
VilleIUT *tiut[200];
V = Chargement(V);
afficher(V);
n=chargeResultat(tiut ,200);
n=(n+1)/4;
printf("%d",n);
affichage(tiut,n);
int choix;
printf("\n\nUtilisateur - 1\tAdministrateur - 2\n\n");
scanf("%d",&choix);

Loading…
Cancel
Save