You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
2.3 KiB
96 lines
2.3 KiB
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "iut.h"
|
|
|
|
void MenuUtilisateur(VilleIUT *tiut[], int n){
|
|
int choix, succes;
|
|
while(choix!=5){
|
|
printf("\n1 - Recherche d'un IUT\n2 - Départements dans chaque IUT\n3 - Nombre de places en première année\n4 - Recherche d'un département\n5 - Quitter\n");
|
|
scanf("%d%*c",&choix);
|
|
if(choix==1){
|
|
//Recherche de tel IUT
|
|
succes = rechercheIUT(tiut, n);
|
|
}
|
|
if(choix==2){
|
|
succes = rechercheDept(tiut, n);
|
|
}
|
|
if(choix==3){
|
|
succes = recherchePlaces(tiut, n);
|
|
}
|
|
if(choix==4){
|
|
//
|
|
}
|
|
if(choix==5){
|
|
return;
|
|
}
|
|
/*
|
|
if(succes != 0){
|
|
//something
|
|
}*/
|
|
}
|
|
}
|
|
|
|
int rechercheIUT(VilleIUT *tiut[], int n){
|
|
char rech[31];
|
|
int i, trouve = 0;
|
|
printf("\nEntrez le nom d'une ville ou d'un IUT : ");
|
|
scanf("%s%*c", &rech);
|
|
for(i=0;i<n && trouve!=1;i++){
|
|
if(strcmp(tiut[i]->ville, rech)==0){
|
|
printf("\nIl y a un IUT à %s.\n", rech);
|
|
trouve = 1;
|
|
return 0;
|
|
}
|
|
else if(i==n-1)
|
|
printf("\nIl n'y pas d'IUT dans votre ville.\n");
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
int rechercheDept(VilleIUT *tiut[], int n){
|
|
char rech[31];
|
|
int i, trouve = 0, j = 0;
|
|
ListeD ld = tiut[i]->ldept;
|
|
printf("\nEntrez le nom d'une ville ou d'un IUT : ");
|
|
scanf("%s%*c", &rech);
|
|
for(i=0;i<n && trouve!=1;i++){
|
|
if(strcmp(tiut[i]->ville, rech)==0){
|
|
printf("\nListe des départements :\n\n");
|
|
while(ld!=NULL){
|
|
printf("%s\t",ld->departement);
|
|
printf("Responsable : %s\n",ld->resp);
|
|
ld = ld->suivant;
|
|
return 0;
|
|
}
|
|
trouve = 1;
|
|
}
|
|
else if(i==n-1)
|
|
printf("\nAucun département trouvé, il n'y pas d'IUT dans votre ville.\n");
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
//FONCTIONNE PAS ENCORE, ERREUR DE SEGMENTATION :
|
|
int recherchePlaces(VilleIUT *tiut[], int n){
|
|
int err;
|
|
char rech[31];
|
|
int i, trouve = 0;
|
|
printf("OK");
|
|
//err = rechercheDept(tiut, n); ERREUR ICI
|
|
printf("OK");
|
|
printf("Quel département ? ");
|
|
printf("OK");
|
|
scanf("%s", &rech);
|
|
for(i=0;i<n && trouve!=1;i++){ //Ici, je ne suis pas sûr je la boucle, il faudrait peut-être mettre la condition *pour *
|
|
if(strcmp(tiut[i]->ldept->departement, rech)==0){
|
|
printf("\nNombre de places disponibles : %d\n\n", tiut[i]->ldept->nbP);
|
|
trouve = 1;
|
|
return 0;
|
|
}
|
|
else if(i==n-1)
|
|
printf("\nAucun département trouvé, il n'y pas d'IUT dans votre ville.\n");
|
|
}
|
|
return 1;
|
|
}
|