Ajout de multiples fonctions, modification de tous les fichiers et ajout du fichier 'iut.c'

master
Nicolas BLONDEAU 2 years ago
parent 68f4209b15
commit 7584bcf8f7

@ -0,0 +1,50 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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);
}*/
//------------------------------------------------------------------------------

58
iut.c

@ -0,0 +1,58 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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);
}

32
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);

@ -0,0 +1,30 @@
#include <stdio.h>
#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);
}
}
Loading…
Cancel
Save