parent
bf25a8f63c
commit
a2acc3581c
@ -1,231 +1,271 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "iut.h"
|
||||
|
||||
//chargement candidat
|
||||
int chargementcandidat(Candidat *tcandidat[],int tmax){
|
||||
int i = 0, j=0;
|
||||
int nbChoix = 0;
|
||||
Candidat C;
|
||||
Choix ch;
|
||||
FILE *fe1;
|
||||
fe1=fopen("Candidat.don","r");
|
||||
if(fe1==NULL){
|
||||
printf("Problème d'ouverture du fichier Candidat");
|
||||
return-1;
|
||||
}
|
||||
C = lireCandidat(fe1, &nbChoix);
|
||||
|
||||
while(!feof(fe1)){
|
||||
tcandidat[i] = (Candidat*)malloc(sizeof(Candidat));
|
||||
if(tcandidat[i]==NULL){
|
||||
printf("Problème de malloc");
|
||||
return -3;
|
||||
}
|
||||
*tcandidat[i] = C;
|
||||
for(j = 0; j < nbChoix; j++){
|
||||
|
||||
ch = lireChoix(fe1);
|
||||
tcandidat[i]->lchoix = InsertionCandidat(tcandidat[i]->lchoix, ch.ville, ch.departement, ch.decision, ch.validation);
|
||||
}
|
||||
C = lireCandidat(fe1, &nbChoix);
|
||||
i++;
|
||||
}
|
||||
fclose(fe1);
|
||||
return i;
|
||||
}
|
||||
Candidat lireCandidat(FILE *fe1, int *nbChoix){
|
||||
Candidat C;
|
||||
C.lchoix = NULL;
|
||||
fscanf(fe1,"%d %s %s %f %f %f %f %d", &C.numero, C.nom, C.prenom, &C.note.Francais, &C.note.Maths, &C.note.Anglais, &C.note.special, &C.nb_choix);
|
||||
*nbChoix=C.nb_choix;
|
||||
return C;
|
||||
}
|
||||
Choix lireChoix(FILE *fe1){
|
||||
Choix ch;
|
||||
fscanf(fe1,"%s %s %d %d", ch.ville, ch.departement, &ch.decision, &ch.validation);
|
||||
return ch;
|
||||
}
|
||||
ListeC InsertionTeteCandidat(ListeC ld, char *ville, char *departement, int decision, int validation){
|
||||
Choix *ch;
|
||||
ch = (Choix*)malloc(sizeof(Choix));
|
||||
if(ch==NULL){
|
||||
printf("Problème malloc m");
|
||||
exit(1);}
|
||||
strcpy(ch->ville, ville);
|
||||
strcpy(ch->departement, departement);
|
||||
ch->decision = decision;
|
||||
ch->validation = validation;
|
||||
ch->suivant = ld;
|
||||
return ch;
|
||||
}
|
||||
ListeC InsertionCandidat(ListeC ld, char *ville, char *departement, int decision, int validation){
|
||||
if(ld==NULL)
|
||||
return InsertionTeteCandidat(ld, ville, departement, decision, validation);
|
||||
if(strcmp(ld->ville, ville)<0)
|
||||
return InsertionTeteCandidat(ld, ville, departement, decision, validation);
|
||||
ld->suivant = InsertionCandidat(ld->suivant, ville, departement, decision, validation);
|
||||
return ld;
|
||||
}
|
||||
//affichage Candidat+choix
|
||||
void affichageCandidatchoix(Candidat *tcandidat[],int n){
|
||||
int i;
|
||||
for(i=0;i<n;i++){
|
||||
afficheCandidat(tcandidat, i);
|
||||
affichageListeCandidatchoix(tcandidat[i]->lchoix);
|
||||
}
|
||||
}
|
||||
void afficheCandidat(Candidat *tcandidat[], int i){
|
||||
printf("\n%d\t", tcandidat[i]->numero);
|
||||
printf("%s ", tcandidat[i]->nom);
|
||||
printf("%s\t", tcandidat[i]->prenom);
|
||||
printf("%.2f\t", tcandidat[i]->note.Francais);
|
||||
printf("%.2f\t", tcandidat[i]->note.Maths);
|
||||
printf("%.2f\t", tcandidat[i]->note.Anglais);
|
||||
printf("%.2f\t", tcandidat[i]->note.special);
|
||||
printf("%d\n", tcandidat[i]->nb_choix);
|
||||
}
|
||||
void affichageListeCandidatchoix(ListeC ld){
|
||||
while(ld!=NULL){
|
||||
printf("%s\t",ld->ville);
|
||||
printf("%s\t",ld->departement);
|
||||
printf("%d\t",ld->decision);
|
||||
printf("%d\n",ld->validation);
|
||||
ld = ld->suivant;
|
||||
}
|
||||
}
|
||||
// Menu Candidat
|
||||
void MenuCandidat(Candidat *tcandidat[],VilleIUT *tiut[],int nc){
|
||||
int Achoix, choix, i, j, comp, comp1, numero, place;
|
||||
char Ncandidat[30], PNcandidat[30], departement[30], newdepart[30], Vmodif[30], Ville[30];
|
||||
printf("\n0-Revenir au menu\t1-Etudiant\t2-departement\n:");
|
||||
scanf("\n%d",&Achoix);
|
||||
while(Achoix>0 && Achoix<3){
|
||||
if(Achoix==1){
|
||||
// a toi nicolas
|
||||
printf("\n\nVeuillez saisir votre numero de Candidat(si revenir au menu - 0)\n:");
|
||||
scanf("%d",&numero);
|
||||
if(numero==0){
|
||||
Achoix=0;
|
||||
break;
|
||||
}
|
||||
place=verificationid(tcandidat, numero, nc);
|
||||
if(place==-1){
|
||||
printf("pb numero inconnu");
|
||||
exit(1);
|
||||
}
|
||||
printf("\nVos choix\n");
|
||||
affichageListeCandidatchoix(tcandidat[place]->lchoix);
|
||||
printf("\n0-Revenir au menu\n1-modifier\n2-ajouter\n3-supprimer\n:");
|
||||
scanf("%d",&choix);
|
||||
while(choix>0){
|
||||
if(choix==1){
|
||||
printf("\nVille où voulez modifier : ");
|
||||
scanf("%s",Ville);
|
||||
printf("\nDepartement lier : ");
|
||||
scanf("%s",departement);
|
||||
printf("\nNouvelle Ville : ");
|
||||
scanf("%s",Vmodif);
|
||||
printf("\nNouveau Departement lier : ");
|
||||
scanf("%s",newdepart);
|
||||
tcandidat[place]->lchoix=modifCandidat(tcandidat[place]->lchoix, departement, newdepart, Ville, Vmodif, nc);
|
||||
affichageListeCandidatchoix(tcandidat[place]->lchoix);
|
||||
printf("\n0-Revenir au menu\n1-modifier\n2-ajouter\n3-supprimer\n:");
|
||||
scanf("%d",&choix);
|
||||
}
|
||||
if(choix==2){
|
||||
|
||||
}
|
||||
if(choix==3){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Achoix==2){
|
||||
printf("\n0-Revenir au menu\n1-Afficher Info pour un Candidat\n2-Afficher tout les Candidat par departement\n3-Afficher tout les Candidat avec leur information\n:");
|
||||
scanf("\n%d",&choix);
|
||||
if(choix==0){
|
||||
Achoix=0;
|
||||
break;
|
||||
}
|
||||
while(choix>0){
|
||||
if(choix==1){
|
||||
printf("\nnom du candidat:");
|
||||
scanf("%s",Ncandidat);
|
||||
printf("\nprenom du candidat:");
|
||||
scanf("%s",PNcandidat);
|
||||
for(i=0;i<nc;i++){
|
||||
comp=strcmp(tcandidat[i]->nom, Ncandidat);
|
||||
comp1=strcmp(tcandidat[i]->prenom, PNcandidat);
|
||||
if(comp==0 && comp1==0){
|
||||
afficheCandidat(tcandidat, i);
|
||||
affichageListeCandidatchoix(tcandidat[i]->lchoix);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(choix==2){
|
||||
printf("\nnom du departement souhaiter :");
|
||||
scanf("%s",departement);
|
||||
for(i=0;i<nc;i++){
|
||||
if(rechercheCandidatParDeaprtement(tcandidat[i]->lchoix,departement, nc) ==0){
|
||||
afficheCandidat(tcandidat, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(choix==3){
|
||||
printf("\n\n\n\t\tTableau Candidat et choix\n");
|
||||
affichageCandidatchoix(tcandidat,nc);
|
||||
}
|
||||
printf("\nVoulez-vous choisir une autre fonction ? Sinon taper 0 pour valider : ");
|
||||
scanf("%d%*c",&choix);
|
||||
if(choix==0){
|
||||
Achoix=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int rechercheCandidatParDeaprtement(ListeC ld,char *departement, int nc){
|
||||
int emp,i=0;
|
||||
while(ld!=NULL){
|
||||
emp = strcmp(departement, ld->departement);
|
||||
if(emp==0)
|
||||
return emp;
|
||||
ld = ld->suivant;
|
||||
}
|
||||
return-1;
|
||||
}
|
||||
int rechercheCandidatParVille(ListeC ld,char *departement ,char *Ville, int nc){
|
||||
int emp,emp1,i=0;
|
||||
while(ld!=NULL){
|
||||
emp = strcmp(Ville, ld->ville);
|
||||
emp1 = strcmp(departement, ld->departement);
|
||||
if(emp==0 && emp1==0)
|
||||
return emp;
|
||||
ld = ld->suivant;
|
||||
}
|
||||
return-1;
|
||||
}
|
||||
int verificationid(Candidat *tcandidat[], int numero, int nc){
|
||||
int i;
|
||||
for(i=0;i<nc;i++){
|
||||
if(tcandidat[i]->numero==numero)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
ListeC modifCandidat(ListeC ld, char *departement, char *newdepart, char *Ville, char *newVille, int n){
|
||||
int comp, comp1, trouv, i;
|
||||
for(i=0;i<=n;i++){
|
||||
comp=strcmp(ld->departement,departement);
|
||||
comp1=strcmp(ld->ville,Ville);
|
||||
if(comp==0 && comp1==0){
|
||||
strcpy(ld->departement, newdepart);
|
||||
strcpy(ld->ville, newVille);
|
||||
return ld;
|
||||
}
|
||||
ld=ld->suivant;
|
||||
}
|
||||
}
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "iut.h"
|
||||
|
||||
//chargement candidat
|
||||
int chargementcandidat(Candidat *tcandidat[],int tmax){
|
||||
int i = 0, j=0;
|
||||
int nbChoix = 0;
|
||||
Candidat C;
|
||||
Choix ch;
|
||||
FILE *fe1;
|
||||
fe1=fopen("Candidat.don","r");
|
||||
if(fe1==NULL){
|
||||
printf("Problème d'ouverture du fichier Candidat");
|
||||
return-1;
|
||||
}
|
||||
C = lireCandidat(fe1);
|
||||
while(!feof(fe1)){
|
||||
tcandidat[i] = (Candidat*)malloc(sizeof(Candidat));
|
||||
if(tcandidat[i]==NULL){
|
||||
printf("Problème de malloc");
|
||||
return -3;
|
||||
}
|
||||
*tcandidat[i] = C;
|
||||
for(j = 0; j < tcandidat[i]->nb_choix; j++){
|
||||
ch = lireChoix(fe1);
|
||||
tcandidat[i]->lchoix = InsertionCandidat(tcandidat[i]->lchoix, ch.ville, ch.departement, ch.decision, ch.validation);
|
||||
}
|
||||
C = lireCandidat(fe1);
|
||||
i++;
|
||||
}
|
||||
fclose(fe1);
|
||||
return i;
|
||||
}
|
||||
Candidat lireCandidat(FILE *fe1){
|
||||
Candidat C;
|
||||
C.lchoix = NULL;
|
||||
fscanf(fe1,"%d %s %s %f %f %f %d", &C.numero, C.nom, C.prenom, &C.note.Francais, &C.note.Maths, &C.note.Anglais, &C.nb_choix);
|
||||
return C;
|
||||
}
|
||||
Choix lireChoix(FILE *fe1){
|
||||
Choix ch;
|
||||
fscanf(fe1,"%s %s %d %d", ch.ville, ch.departement, &ch.decision, &ch.validation);
|
||||
return ch;
|
||||
}
|
||||
ListeC InsertionTeteCandidat(ListeC ld, char *ville, char *departement, int decision, int validation){
|
||||
Choix *ch;
|
||||
ch = (Choix*)malloc(sizeof(Choix));
|
||||
if(ch==NULL){
|
||||
printf("Problème malloc m");
|
||||
exit(1);}
|
||||
strcpy(ch->ville, ville);
|
||||
strcpy(ch->departement, departement);
|
||||
ch->decision = decision;
|
||||
ch->validation = validation;
|
||||
ch->suivant = ld;
|
||||
return ch;
|
||||
}
|
||||
ListeC InsertionCandidat(ListeC ld, char *ville, char *departement, int decision, int validation){
|
||||
if(ld==NULL)
|
||||
return InsertionTeteCandidat(ld, ville, departement, decision, validation);
|
||||
if(strcmp(ld->ville, ville)<0)
|
||||
return InsertionTeteCandidat(ld, ville, departement, decision, validation);
|
||||
ld->suivant = InsertionCandidat(ld->suivant, ville, departement, decision, validation);
|
||||
return ld;
|
||||
}
|
||||
//affichage Candidat+choix
|
||||
void affichageCandidatchoix(Candidat *tcandidat[],int n){
|
||||
int i;
|
||||
for(i=0;i<n;i++){
|
||||
afficheCandidat(tcandidat, i);
|
||||
affichageListeCandidatchoix(tcandidat[i]->lchoix);
|
||||
}
|
||||
}
|
||||
void afficheCandidat(Candidat *tcandidat[], int i){
|
||||
printf("\n%d\t", tcandidat[i]->numero);
|
||||
printf("%s ", tcandidat[i]->nom);
|
||||
printf("%s\t", tcandidat[i]->prenom);
|
||||
printf("%.2f\t", tcandidat[i]->note.Francais);
|
||||
printf("%.2f\t", tcandidat[i]->note.Maths);
|
||||
printf("%.2f\t", tcandidat[i]->note.Anglais);
|
||||
printf("%d\n", tcandidat[i]->nb_choix);
|
||||
}
|
||||
void affichageListeCandidatchoix(ListeC ld){
|
||||
while(ld!=NULL){
|
||||
printf("%s\t",ld->ville);
|
||||
printf("%s\t",ld->departement);
|
||||
printf("%d\t",ld->decision);
|
||||
printf("%d\n",ld->validation);
|
||||
ld = ld->suivant;
|
||||
}
|
||||
}
|
||||
// Menu Candidat
|
||||
void MenuCandidat(Candidat *tcandidat[],VilleIUT *tiut[],int nc){
|
||||
int Achoix, choix, i, j, comp, comp1, numero, place;
|
||||
char Ncandidat[30], PNcandidat[30], departement[30], newdepart[30], Vmodif[30], Ville[30];
|
||||
printf("\n0-Revenir au menu\t1-Etudiant\t2-departement\n:");
|
||||
scanf("\n%d",&Achoix);
|
||||
while(Achoix>0 && Achoix<3){
|
||||
while(Achoix==1){
|
||||
printf("\n\nVeuillez saisir votre numero de Candidat(si revenir au menu - 0)\n:");
|
||||
scanf("%d",&numero);
|
||||
if(numero==0){
|
||||
Achoix=0;
|
||||
break;
|
||||
}
|
||||
place=verificationid(tcandidat, numero, nc);
|
||||
if(place==-1){
|
||||
printf("pb numero inconnu");
|
||||
exit(1);
|
||||
}
|
||||
printf("\nVos choix\n");
|
||||
affichageListeCandidatchoix(tcandidat[place]->lchoix);
|
||||
printf("\n0-Revenir au menu\n1-modifier\n2-ajouter\n3-supprimer\n:");
|
||||
scanf("%d",&choix);
|
||||
while(choix>0){
|
||||
if(choix==1){
|
||||
printf("\nVille où voulez modifier : ");
|
||||
scanf("%s",Ville);
|
||||
printf("\nDepartement lier : ");
|
||||
scanf("%s",departement);
|
||||
printf("\nNouvelle Ville : ");
|
||||
scanf("%s",Vmodif);
|
||||
printf("\nNouveau Departement lier : ");
|
||||
scanf("%s",newdepart);
|
||||
tcandidat[place]->lchoix=modifCandidat(tcandidat[place]->lchoix, departement, newdepart, Ville, Vmodif, nc);
|
||||
}
|
||||
if(choix==2){
|
||||
printf("\nVille a ajouter : ");
|
||||
scanf("%s",Ville);
|
||||
printf("\nDepartement lier : ");
|
||||
scanf("%s",departement);
|
||||
tcandidat[place]->lchoix=ajoutCandidat(tcandidat[place]->lchoix, departement, Ville);
|
||||
}
|
||||
if(choix==3){
|
||||
printf("\nVille a supprimer : ");
|
||||
scanf("%s",Ville);
|
||||
printf("\nDepartement lier : ");
|
||||
scanf("%s",departement);
|
||||
tcandidat[place]->lchoix=suppressionCandidat(tcandidat[place]->lchoix, departement, Ville);
|
||||
}
|
||||
affichageListeCandidatchoix(tcandidat[place]->lchoix);
|
||||
printf("\n0-Revenir au menu\n1-modifier\n2-ajouter\n3-supprimer\n:");
|
||||
scanf("%d",&choix);
|
||||
}
|
||||
}
|
||||
while(Achoix==2){
|
||||
printf("\n0-Revenir au menu\n1-Afficher Info pour un Candidat\n2-Afficher tout les Candidat par departement\n3-Afficher tout les Candidat avec leur information\n:");
|
||||
scanf("\n%d",&choix);
|
||||
if(choix==0){
|
||||
Achoix=0;
|
||||
break;
|
||||
}
|
||||
while(choix>0){
|
||||
if(choix==1){
|
||||
printf("\nnom du candidat:");
|
||||
scanf("%s",Ncandidat);
|
||||
printf("\nprenom du candidat:");
|
||||
scanf("%s",PNcandidat);
|
||||
for(i=0;i<nc;i++){
|
||||
comp=strcmp(tcandidat[i]->nom, Ncandidat);
|
||||
comp1=strcmp(tcandidat[i]->prenom, PNcandidat);
|
||||
if(comp==0 && comp1==0){
|
||||
afficheCandidat(tcandidat, i);
|
||||
affichageListeCandidatchoix(tcandidat[i]->lchoix);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(choix==2){
|
||||
printf("\nnom du departement souhaiter :");
|
||||
scanf("%s",departement);
|
||||
for(i=0;i<nc;i++){
|
||||
if(rechercheCandidatParDeaprtement(tcandidat[i]->lchoix,departement, nc) ==0){
|
||||
afficheCandidat(tcandidat, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(choix==3){
|
||||
printf("\n\n\n\t\tTableau Candidat et choix\n");
|
||||
affichageCandidatchoix(tcandidat,nc);
|
||||
}
|
||||
printf("\nVoulez-vous choisir une autre fonction ? Sinon taper 0 pour valider : ");
|
||||
scanf("%d%*c",&choix);
|
||||
if(choix==0){
|
||||
Achoix=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int rechercheCandidatParDeaprtement(ListeC ld,char *departement, int nc){
|
||||
int emp,i=0;
|
||||
while(ld!=NULL){
|
||||
emp = strcmp(departement, ld->departement);
|
||||
if(emp==0)
|
||||
return emp;
|
||||
ld = ld->suivant;
|
||||
}
|
||||
return-1;
|
||||
}
|
||||
int rechercheCandidatParVille(ListeC ld,char *departement ,char *Ville, int nc){
|
||||
int emp,emp1,i=0;
|
||||
while(ld!=NULL){
|
||||
emp = strcmp(Ville, ld->ville);
|
||||
emp1 = strcmp(departement, ld->departement);
|
||||
if(emp==0 && emp1==0)
|
||||
return emp;
|
||||
ld = ld->suivant;
|
||||
}
|
||||
return-1;
|
||||
}
|
||||
int verificationid(Candidat *tcandidat[], int numero, int nc){
|
||||
int i;
|
||||
for(i=0;i<nc;i++){
|
||||
if(tcandidat[i]->numero==numero)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
ListeC modifCandidat(ListeC ld, char *departement, char *newdepart, char *Ville, char *newVille, int n){
|
||||
int comp, comp1, trouv, i;
|
||||
for(i=0;i<=n;i++){
|
||||
comp=strcmp(ld->departement,departement);
|
||||
comp1=strcmp(ld->ville,Ville);
|
||||
if(comp==0 && comp1==0){
|
||||
strcpy(ld->departement, newdepart);
|
||||
strcpy(ld->ville, newVille);
|
||||
return ld;
|
||||
}
|
||||
ld=ld->suivant;
|
||||
}
|
||||
}
|
||||
ListeC ajoutCandidat(ListeC ld, char *departement, char *ville){
|
||||
Choix *ch;
|
||||
ch = (Choix*)malloc(sizeof(Choix));
|
||||
if(ch==NULL){
|
||||
printf("pb ouv malloc");
|
||||
exit(1);
|
||||
}
|
||||
strcpy(ch->departement, departement);
|
||||
strcpy(ch->ville, ville);
|
||||
ch->decision=0;
|
||||
ch->validation=0;
|
||||
ch->suivant= NULL;
|
||||
if(ld == NULL)
|
||||
ld = ch;
|
||||
else{
|
||||
Choix *chD;
|
||||
chD = ld;
|
||||
while(chD->suivant != NULL)
|
||||
chD = chD->suivant;
|
||||
chD->suivant=ch;
|
||||
}
|
||||
return ld;
|
||||
}
|
||||
ListeC suppressionTeteCandidat(ListeC ld){
|
||||
ListeC ldsvt;
|
||||
ldsvt=ld->suivant;
|
||||
free(ld);
|
||||
return ldsvt;
|
||||
}
|
||||
ListeC suppressionCandidat(ListeC ld,char *departement, char *ville){
|
||||
if(ld==NULL)
|
||||
return ld;
|
||||
if(strcmp(ld->departement, departement) ==0 && strcmp(ld->ville, ville) ==0)
|
||||
return suppressionTeteCandidat(ld);
|
||||
ld->suivant=suppressionCandidat(ld->suivant,departement, ville);
|
||||
return ld;
|
||||
}
|
@ -1,97 +1,97 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "iut.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//Fonction qui teste si la liste est vide ou non, et renvoie 'Vrai si la liste est vide', sinon 'Faux'
|
||||
Booleen testVide(VilleIUT V){
|
||||
if(V.ville == NULL)
|
||||
return vrai;
|
||||
return faux;
|
||||
}
|
||||
|
||||
//chargement Ville+iut
|
||||
int chargement(VilleIUT *tiut[],int tmax){
|
||||
int i = 0, j=0;
|
||||
VilleIUT V;
|
||||
MaillonDept m;
|
||||
FILE *fe;
|
||||
fe=fopen("ville.don","r");
|
||||
if(fe==NULL){
|
||||
printf("Problème d'ouverture du fichier");
|
||||
return-1;
|
||||
}
|
||||
|
||||
V = lireVille(fe);
|
||||
|
||||
while(!feof(fe)){
|
||||
tiut[i] = (VilleIUT*)malloc(sizeof(VilleIUT));
|
||||
if(tiut[i]==NULL){
|
||||
printf("Problème de malloc");
|
||||
return -3;
|
||||
}
|
||||
*tiut[i] = V;
|
||||
for(j = 0; j < tiut[i]->nbDep; j++){
|
||||
m = lireDep(fe);
|
||||
tiut[i]->ldept = Insertion(tiut[i]->ldept, m.departement, m.nbP, m.resp, m.AouD);
|
||||
}
|
||||
V = lireVille(fe);
|
||||
i++;
|
||||
}
|
||||
fclose(fe);
|
||||
return i;
|
||||
}
|
||||
VilleIUT lireVille(FILE *fe){
|
||||
VilleIUT V;
|
||||
V.ldept = NULL;
|
||||
fscanf(fe,"%s %d", V.ville, &V.nbDep);
|
||||
return V;
|
||||
}
|
||||
|
||||
MaillonDept lireDep(FILE *fe){
|
||||
MaillonDept m;
|
||||
fscanf(fe,"%s %d %s %c", m.departement, &m.nbP, m.resp, &m.AouD);
|
||||
return m;
|
||||
}
|
||||
|
||||
ListeD InsertionTete(ListeD ld, char *departement, int nbP,char *resp, char AouD){
|
||||
MaillonDept *m;
|
||||
m = (MaillonDept*)malloc(sizeof(MaillonDept));
|
||||
if(m==NULL){
|
||||
printf("Problème malloc m");
|
||||
exit(1);}
|
||||
strcpy(m->departement, departement);
|
||||
m->nbP = nbP;
|
||||
strcpy(m->resp, resp);
|
||||
m->AouD = AouD;
|
||||
m->suivant = ld;
|
||||
return m;
|
||||
}
|
||||
|
||||
ListeD Insertion(ListeD ld, char *departement, int nbP,char *resp, char AouD){
|
||||
if(ld==NULL)
|
||||
return InsertionTete(ld, departement, nbP, resp, AouD);
|
||||
if(strcmp(ld->departement, departement)<0)
|
||||
return InsertionTete(ld, departement, nbP, resp, AouD);
|
||||
ld->suivant = Insertion(ld->suivant, departement, nbP, resp, AouD);
|
||||
return ld;
|
||||
}
|
||||
//affichage Ville+departement..
|
||||
void affichage (VilleIUT *tiut[],int n){
|
||||
int i;
|
||||
for(i=0;i<n;i++){
|
||||
printf("\n%s\t%d\n", tiut[i]->ville, tiut[i]->nbDep);
|
||||
affichageListe(tiut[i]->ldept);
|
||||
}
|
||||
}
|
||||
void affichageListe(ListeD ld){
|
||||
while(ld!=NULL){
|
||||
printf("%s\t",ld->departement);
|
||||
printf("%d\t",ld->nbP);
|
||||
printf("%s\t",ld->resp);
|
||||
printf("%c\n",ld->AouD);
|
||||
ld = ld->suivant;}
|
||||
}
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "iut.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//Fonction qui teste si la liste est vide ou non, et renvoie 'Vrai si la liste est vide', sinon 'Faux'
|
||||
Booleen testVide(VilleIUT V){
|
||||
if(V.ville == NULL)
|
||||
return vrai;
|
||||
return faux;
|
||||
}
|
||||
|
||||
//chargement Ville+iut
|
||||
int chargement(VilleIUT *tiut[],int tmax){
|
||||
int i = 0, j=0;
|
||||
VilleIUT V;
|
||||
MaillonDept m;
|
||||
FILE *fe;
|
||||
fe=fopen("ville.don","r");
|
||||
if(fe==NULL){
|
||||
printf("Problème d'ouverture du fichier");
|
||||
return-1;
|
||||
}
|
||||
|
||||
V = lireVille(fe);
|
||||
|
||||
while(!feof(fe)){
|
||||
tiut[i] = (VilleIUT*)malloc(sizeof(VilleIUT));
|
||||
if(tiut[i]==NULL){
|
||||
printf("Problème de malloc");
|
||||
return -3;
|
||||
}
|
||||
*tiut[i] = V;
|
||||
for(j = 0; j < tiut[i]->nbDep; j++){
|
||||
m = lireDep(fe);
|
||||
tiut[i]->ldept = Insertion(tiut[i]->ldept, m.departement, m.nbP, m.resp, m.AouD);
|
||||
}
|
||||
V = lireVille(fe);
|
||||
i++;
|
||||
}
|
||||
fclose(fe);
|
||||
return i;
|
||||
}
|
||||
VilleIUT lireVille(FILE *fe){
|
||||
VilleIUT V;
|
||||
V.ldept = NULL;
|
||||
fscanf(fe,"%s %d", V.ville, &V.nbDep);
|
||||
return V;
|
||||
}
|
||||
|
||||
MaillonDept lireDep(FILE *fe){
|
||||
MaillonDept m;
|
||||
fscanf(fe,"%s %d %s %c", m.departement, &m.nbP, m.resp, &m.AouD);
|
||||
return m;
|
||||
}
|
||||
|
||||
ListeD InsertionTete(ListeD ld, char *departement, int nbP,char *resp, char AouD){
|
||||
MaillonDept *m;
|
||||
m = (MaillonDept*)malloc(sizeof(MaillonDept));
|
||||
if(m==NULL){
|
||||
printf("Problème malloc m");
|
||||
exit(1);}
|
||||
strcpy(m->departement, departement);
|
||||
m->nbP = nbP;
|
||||
strcpy(m->resp, resp);
|
||||
m->AouD = AouD;
|
||||
m->suivant = ld;
|
||||
return m;
|
||||
}
|
||||
|
||||
ListeD Insertion(ListeD ld, char *departement, int nbP,char *resp, char AouD){
|
||||
if(ld==NULL)
|
||||
return InsertionTete(ld, departement, nbP, resp, AouD);
|
||||
if(strcmp(ld->departement, departement)<0)
|
||||
return InsertionTete(ld, departement, nbP, resp, AouD);
|
||||
ld->suivant = Insertion(ld->suivant, departement, nbP, resp, AouD);
|
||||
return ld;
|
||||
}
|
||||
//affichage Ville+departement..
|
||||
void affichage (VilleIUT *tiut[],int n){
|
||||
int i;
|
||||
for(i=0;i<n;i++){
|
||||
printf("\n%s\t%d\n", tiut[i]->ville, tiut[i]->nbDep);
|
||||
affichageListe(tiut[i]->ldept);
|
||||
}
|
||||
}
|
||||
void affichageListe(ListeD ld){
|
||||
while(ld!=NULL){
|
||||
printf("%s\t",ld->departement);
|
||||
printf("%d\t",ld->nbP);
|
||||
printf("%s\t",ld->resp);
|
||||
printf("%c\n",ld->AouD);
|
||||
ld = ld->suivant;}
|
||||
}
|
||||
|
@ -1,101 +1,103 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
// Structure pour stocker les informations sur un choix d'un candidat
|
||||
typedef struct{
|
||||
float Francais;
|
||||
float Maths;
|
||||
float Anglais;
|
||||
float special;
|
||||
}note;
|
||||
|
||||
typedef struct liste2 {
|
||||
char ville[50];
|
||||
char departement[50];
|
||||
int decision;
|
||||
int validation;
|
||||
struct liste2 *suivant;
|
||||
} Choix, *ListeC;
|
||||
|
||||
typedef struct liste1{
|
||||
int numero;
|
||||
char nom[50];
|
||||
char prenom[50];
|
||||
note note;
|
||||
float moy;
|
||||
int nb_choix;
|
||||
ListeC lchoix;
|
||||
struct liste1 *suivant;
|
||||
} Candidat;
|
||||
|
||||
|
||||
typedef struct liste{
|
||||
char departement[30];
|
||||
int nbP;
|
||||
char resp[30];
|
||||
char AouD;
|
||||
struct liste *suivant;
|
||||
}MaillonDept, *ListeD;
|
||||
|
||||
typedef struct{
|
||||
char ville[30];
|
||||
int nbDep;
|
||||
ListeD ldept;
|
||||
}VilleIUT;
|
||||
|
||||
|
||||
typedef enum {faux,vrai}Booleen;
|
||||
|
||||
//Menu utilisateur :
|
||||
void MenuUtilisateur(VilleIUT *tiut[],int n);
|
||||
int rechercheIUT(VilleIUT *tiut[],int n);
|
||||
int rechercheDept(VilleIUT *tiut[], int n);
|
||||
int recherchePlaces(VilleIUT *tiut[], int n);
|
||||
int rechercheMixed(VilleIUT *tiut[], int n);
|
||||
|
||||
//Menu administrateur :
|
||||
void MenuAdministrateur(VilleIUT *tiut[],int n);
|
||||
ListeD suppression(ListeD ld,char *departement);
|
||||
ListeD suppressionTete(ListeD ld);
|
||||
ListeD Enfiler(ListeD ld, char *departement, int nbP,char *resp);
|
||||
ListeD ModifinbP(ListeD ld, char departement[30], int MnbP, int n);
|
||||
ListeD ModifiRespon(ListeD ld, char departement[30], char respon[30], int n);
|
||||
ListeD ModifiAouD(ListeD ld, char departement[30], char AouD, int n);
|
||||
|
||||
//Menu Candidat
|
||||
void MenuCandidat(Candidat *tcandidat[],VilleIUT *tiut[],int nc);
|
||||
void afficheCandidat(Candidat *tcandidat[], int i);
|
||||
int rechercheCandidatParDeaprtement(ListeC ld,char *departement, int nc);
|
||||
int rechercheCandidatParVille(ListeC ld, char *departement ,char *Ville, int nc);
|
||||
int verificationid(Candidat *tcandidat[], int numero, int nc);
|
||||
ListeC modifCandidat(ListeC ld, char *departement, char *newdepart, char *Ville, char *newVille, int n);
|
||||
|
||||
//Menu Responsable
|
||||
void MenuRespon(Candidat *tcandidat[], VilleIUT *tiut[], int n,int nc);
|
||||
|
||||
//Liste:
|
||||
VilleIUT Initialisation(void);
|
||||
Booleen testVide(VilleIUT V);
|
||||
void afficher (VilleIUT V);
|
||||
VilleIUT defiler(VilleIUT V);
|
||||
|
||||
//chargement Ville+departement
|
||||
int chargement(VilleIUT *tiut[],int tmax);
|
||||
MaillonDept lireDep(FILE *fe);
|
||||
VilleIUT lireVille(FILE *fe);
|
||||
ListeD Insertion(ListeD ld, char *departement, int nbP,char *resp, char AouD);
|
||||
ListeD InsertionTete(ListeD ld, char *departement, int nbP,char *resp, char AouD);
|
||||
void affichage (VilleIUT *tiut[],int n);
|
||||
void affichageListe(ListeD ld);
|
||||
|
||||
//Candidat+choix
|
||||
int chargementcandidat(Candidat *tcandidat[],int tmax);
|
||||
Candidat lireCandidat(FILE *fe1, int *nbChoix);
|
||||
Choix lireChoix(FILE *fe1);
|
||||
ListeC InsertionTeteCandidat(ListeC ld, char *ville, char *departement, int decision, int validation); ListeC InsertionCandidat(ListeC ld, char *ville, char *departement, int decision, int validation);
|
||||
void affichageCandidatchoix(Candidat *tcandidat[],int n);
|
||||
void affichageListeCandidatchoix(ListeC ld);
|
||||
|
||||
// fonction de sauvegarde
|
||||
int fsauvegarde(VilleIUT *tiut[], Candidat *tcandidat[], int n, int nc, int choix, int tmax);
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
// Structure pour stocker les informations sur un choix d'un candidat
|
||||
typedef struct{
|
||||
float Francais;
|
||||
float Maths;
|
||||
float Anglais;
|
||||
}note;
|
||||
|
||||
typedef struct liste2 {
|
||||
char ville[50];
|
||||
char departement[50];
|
||||
int decision;
|
||||
int validation;
|
||||
struct liste2 *suivant;
|
||||
} Choix, *ListeC;
|
||||
|
||||
typedef struct liste1{
|
||||
int numero;
|
||||
char nom[50];
|
||||
char prenom[50];
|
||||
note note;
|
||||
float moy;
|
||||
int nb_choix;
|
||||
ListeC lchoix;
|
||||
struct liste1 *suivant;
|
||||
} Candidat;
|
||||
|
||||
|
||||
typedef struct liste{
|
||||
char departement[30];
|
||||
int nbP;
|
||||
char resp[30];
|
||||
char AouD;
|
||||
struct liste *suivant;
|
||||
}MaillonDept, *ListeD;
|
||||
|
||||
typedef struct{
|
||||
char ville[30];
|
||||
int nbDep;
|
||||
ListeD ldept;
|
||||
}VilleIUT;
|
||||
|
||||
|
||||
typedef enum {faux,vrai}Booleen;
|
||||
|
||||
//Menu utilisateur :
|
||||
void MenuUtilisateur(VilleIUT *tiut[],int n);
|
||||
int rechercheIUT(VilleIUT *tiut[],int n);
|
||||
int rechercheDept(VilleIUT *tiut[], int n);
|
||||
int recherchePlaces(VilleIUT *tiut[], int n);
|
||||
int rechercheMixed(VilleIUT *tiut[], int n);
|
||||
|
||||
//Menu administrateur :
|
||||
void MenuAdministrateur(VilleIUT *tiut[],int n);
|
||||
ListeD suppression(ListeD ld,char *departement);
|
||||
ListeD suppressionTete(ListeD ld);
|
||||
ListeD Enfiler(ListeD ld, char *departement, int nbP,char *resp);
|
||||
ListeD ModifinbP(ListeD ld, char departement[30], int MnbP, int n);
|
||||
ListeD ModifiRespon(ListeD ld, char departement[30], char respon[30], int n);
|
||||
ListeD ModifiAouD(ListeD ld, char departement[30], char AouD, int n);
|
||||
|
||||
//Menu Candidat
|
||||
void MenuCandidat(Candidat *tcandidat[],VilleIUT *tiut[],int nc);
|
||||
void afficheCandidat(Candidat *tcandidat[], int i);
|
||||
int rechercheCandidatParDeaprtement(ListeC ld,char *departement, int nc);
|
||||
int rechercheCandidatParVille(ListeC ld, char *departement ,char *Ville, int nc);
|
||||
int verificationid(Candidat *tcandidat[], int numero, int nc);
|
||||
ListeC modifCandidat(ListeC ld, char *departement, char *newdepart, char *Ville, char *newVille, int n);
|
||||
ListeC ajoutCandidat(ListeC ld, char *departement, char *ville);
|
||||
ListeC suppressionCandidat(ListeC ld,char *departement, char *ville);
|
||||
ListeC suppressionTeteCandidat(ListeC ld);
|
||||
|
||||
//Menu Responsable
|
||||
void MenuRespon(Candidat *tcandidat[], VilleIUT *tiut[], int n,int nc);
|
||||
|
||||
//Liste:
|
||||
VilleIUT Initialisation(void);
|
||||
Booleen testVide(VilleIUT V);
|
||||
void afficher (VilleIUT V);
|
||||
VilleIUT defiler(VilleIUT V);
|
||||
|
||||
//chargement Ville+departement
|
||||
int chargement(VilleIUT *tiut[],int tmax);
|
||||
MaillonDept lireDep(FILE *fe);
|
||||
VilleIUT lireVille(FILE *fe);
|
||||
ListeD Insertion(ListeD ld, char *departement, int nbP,char *resp, char AouD);
|
||||
ListeD InsertionTete(ListeD ld, char *departement, int nbP,char *resp, char AouD);
|
||||
void affichage (VilleIUT *tiut[],int n);
|
||||
void affichageListe(ListeD ld);
|
||||
|
||||
//Candidat+choix
|
||||
int chargementcandidat(Candidat *tcandidat[],int tmax);
|
||||
Candidat lireCandidat(FILE *fe1);
|
||||
Choix lireChoix(FILE *fe1);
|
||||
ListeC InsertionTeteCandidat(ListeC ld, char *ville, char *departement, int decision, int validation); ListeC InsertionCandidat(ListeC ld, char *ville, char *departement, int decision, int validation);
|
||||
void affichageCandidatchoix(Candidat *tcandidat[],int n);
|
||||
void affichageListeCandidatchoix(ListeC ld);
|
||||
|
||||
// fonction de sauvegarde
|
||||
int fsauvegarde(VilleIUT *tiut[], Candidat *tcandidat[], int n, int nc, int choix, int tmax);
|
||||
|
@ -1,67 +1,67 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "iut.h"
|
||||
|
||||
void MenuRespon(Candidat *tcandidat[],VilleIUT *tiut[], int n, int nc){
|
||||
int Achoix, choix, i, j, m, comp, comp1;
|
||||
char Ncandidat[30], PNcandidat[30], departement[30],Ville[30];
|
||||
printf("\nVille où se situe le departement \n:");
|
||||
scanf("%s",Ville);
|
||||
printf("\nVotre Departement\n:");
|
||||
scanf("%s", departement);
|
||||
for(i=0;i<nc;i++){
|
||||
comp=strcmp(tiut[i]->ville, Ville);
|
||||
if(comp==0){
|
||||
for(j=0;j<=tiut[i]->nbDep;j++){
|
||||
if(strcmp(tiut[i]->ldept->departement, departement) == 0 && tiut[i]->ldept->AouD == 'D'){
|
||||
for(m=0;m<nc;m++){
|
||||
if(rechercheCandidatParVille(tcandidat[m]->lchoix,departement,Ville, nc) ==0){
|
||||
afficheCandidat(tcandidat, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
tiut[i]->ldept=tiut[i]->ldept->suivant;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
while(Achoix>0 && Achoix<3){
|
||||
if(Achoix==1){
|
||||
// a toi nicolas
|
||||
}
|
||||
if(Achoix==2){
|
||||
printf("\n0-Revenir au menu\n1-Afficher Info pour un Candidat\n2-Afficher tout les Candidat par departement\n3-Afficher tout les Candidat avec leur information\n:");
|
||||
scanf("\n%d",&choix);
|
||||
while(choix>0 ){
|
||||
if(choix==1){
|
||||
printf("\nnom du candidat:");
|
||||
scanf("%s",Ncandidat);
|
||||
printf("\nprenom du candidat:");
|
||||
scanf("%s",PNcandidat);
|
||||
for(i=0;i<nc;i++){
|
||||
comp=strcmp(tcandidat[i]->nom, Ncandidat);
|
||||
comp1=strcmp(tcandidat[i]->prenom, PNcandidat);
|
||||
if(comp==0 && comp1==0){
|
||||
afficheCandidat(tcandidat, i);
|
||||
affichageListeCandidatchoix(tcandidat[i]->lchoix);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(choix==2){
|
||||
printf("\nnom du departement souhaiter :");
|
||||
scanf("%s",departement);
|
||||
|
||||
}
|
||||
if(choix==3){
|
||||
printf("\n\n\n\t\tTableau Candidat et choix\n");
|
||||
affichageCandidatchoix(tcandidat,nc);
|
||||
}
|
||||
printf("\nVoulez-vous choisir une autre fonction ? Sinon taper 0 pour valider : ");
|
||||
scanf("%d%*c",&choix);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "iut.h"
|
||||
|
||||
void MenuRespon(Candidat *tcandidat[],VilleIUT *tiut[], int n, int nc){
|
||||
int Achoix, choix, i, j, m, comp, comp1;
|
||||
char Ncandidat[30], PNcandidat[30], departement[30],Ville[30];
|
||||
printf("\nVille où se situe le departement \n:");
|
||||
scanf("%s",Ville);
|
||||
printf("\nVotre Departement\n:");
|
||||
scanf("%s", departement);
|
||||
for(i=0;i<nc;i++){
|
||||
comp=strcmp(tiut[i]->ville, Ville);
|
||||
if(comp==0){
|
||||
for(j=0;j<=tiut[i]->nbDep;j++){
|
||||
if(strcmp(tiut[i]->ldept->departement, departement) == 0 && tiut[i]->ldept->AouD == 'D'){
|
||||
for(m=0;m<nc;m++){
|
||||
if(rechercheCandidatParVille(tcandidat[m]->lchoix,departement,Ville, nc) ==0){
|
||||
afficheCandidat(tcandidat, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
tiut[i]->ldept=tiut[i]->ldept->suivant;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
while(Achoix>0 && Achoix<3){
|
||||
if(Achoix==1){
|
||||
// a toi nicolas
|
||||
}
|
||||
if(Achoix==2){
|
||||
printf("\n0-Revenir au menu\n1-Afficher Info pour un Candidat\n2-Afficher tout les Candidat par departement\n3-Afficher tout les Candidat avec leur information\n:");
|
||||
scanf("\n%d",&choix);
|
||||
while(choix>0 ){
|
||||
if(choix==1){
|
||||
printf("\nnom du candidat:");
|
||||
scanf("%s",Ncandidat);
|
||||
printf("\nprenom du candidat:");
|
||||
scanf("%s",PNcandidat);
|
||||
for(i=0;i<nc;i++){
|
||||
comp=strcmp(tcandidat[i]->nom, Ncandidat);
|
||||
comp1=strcmp(tcandidat[i]->prenom, PNcandidat);
|
||||
if(comp==0 && comp1==0){
|
||||
afficheCandidat(tcandidat, i);
|
||||
affichageListeCandidatchoix(tcandidat[i]->lchoix);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(choix==2){
|
||||
printf("\nnom du departement souhaiter :");
|
||||
scanf("%s",departement);
|
||||
|
||||
}
|
||||
if(choix==3){
|
||||
printf("\n\n\n\t\tTableau Candidat et choix\n");
|
||||
affichageCandidatchoix(tcandidat,nc);
|
||||
}
|
||||
printf("\nVoulez-vous choisir une autre fonction ? Sinon taper 0 pour valider : ");
|
||||
scanf("%d%*c",&choix);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
Loading…
Reference in new issue