#include #include #include #include "iut.h" void MenuUtilisateur(VilleIUT *tiut[], int n){ int choix, succes; while(choix!=5){ printf("\n >--------------------------------------------------<\n"); printf("\n\t1 - Recherche d'un IUT"); printf("\n\t2 - Départements dans chaque IUT"); printf("\n\t3 - Nombre de places en première année"); printf("\n\t4 - Recherche d'un département"); printf("\n\t5 - Quitter\n"); printf("\n >--------------------------------------------------<\n"); printf("\n\tVotre choix : "); scanf("%d%*c",&choix); system("cls"); system("clear"); 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){ succes = rechercheMixed(tiut, n); } 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;iville, 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; printf("\nEntrez le nom d'une ville : "); scanf("%s%*c", &rech); for(i=0;ildept; 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; } trouve = 1; } else if(i==n-1) printf("\nAucun département trouvé, il n'y pas d'IUT dans votre ville.\n"); } return 1; } int recherchePlaces(VilleIUT *tiut[], int n){ char rech[31]; int i, trouve = 0, j = 0; ListeD ld; printf("\nEntrez un département : "); scanf("%s%*c", &rech); for(i=0;ildept; if(strcmp(ld->departement, rech)==0){ printf("\nÀ %s :\n", tiut[i]->ville); printf("%s\t", ld->departement); printf("Nombre de places : %d\n",ld->nbP); ld = ld->suivant; } else if(i==n-1) printf("\nAucun département trouvé.\n"); } return 1; } int rechercheMixed(VilleIUT *tiut[], int n){ char rech[31], rech2[31]; int i, trouve = 0, j = 0; ListeD ld; printf("\nEntrez le nom d'une ville : "); scanf("%s%*c", &rech); printf("\nEntrez le nom du département souhaité : "); scanf("%s%*c", &rech2); for(i=0;ildept; if(strcmp(tiut[i]->ville, rech)==0){ while(ld!=NULL){ if(strcmp(ld->departement, rech2)==0){ printf("\nÀ %s :\n", tiut[i]->ville); printf("%s\t", ld->departement); printf("Nombre de places : %d\n",ld->nbP); printf("Responsable : %s\n",ld->resp); trouve = 1; } else if(i==n-1) printf("\nAucun département trouvé.\n"); ld = ld->suivant; } } else if(i==n-1) printf("\nAucun département trouvé pour la ville correspondante.\n"); } printf("\n"); return 1; }