From 9836e42a34e6fcb304edeedb6d1d0ce3e82f4452 Mon Sep 17 00:00:00 2001 From: Alexis LAURENT Date: Fri, 6 Jan 2023 14:58:44 +0100 Subject: [PATCH] 06/01 SAE.c --- SAE.c | 63 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/SAE.c b/SAE.c index bff2001..0cc60ff 100644 --- a/SAE.c +++ b/SAE.c @@ -137,7 +137,7 @@ void gestionMenu(VilleIUT **tiut, int nbEle) clearpage(); break; case 9: - choix = gestionMenuAdmin(); + choix = gestionMenuAdmin(tiut, nbEle); if (choix == -1) return; break; @@ -195,20 +195,24 @@ int gestionMenuAdmin(VilleIUT **tiut, int nbEle) void global(void) { - VilleIUT *tiut[30]; - int nbEle; - //nbEle = chargement(tiut,30); - triEchange(tiut, nbEle); - gestionMenu(tiut, nbEle); + int tailleL, i; + VilleIUT** tab; + char nomFich[20]; + strcpy(nomFich,"iut.txt"); + printf("charg\n"); + tab = chargementVille(nomFich,30,&tailleL); + printf("\n"); + triEchange(tab, tailleL); + AffichageGlobalIUT(tab, tailleL); } void AffichageVille(VilleIUT **tiut, int nbEle) { int i; - printf("\tIUT par ville :"); + printf("\tIUT par ville :\n"); for(i=0;iville); + printf("- %s\n\t",tiut[i]->ville); } } @@ -218,8 +222,7 @@ void AffichageGlobalDepVille(VilleIUT **tiut, int nbEle) printf("\tDépartement par IUT :\n"); for(i=0;iville); - printf(" :\n\t"); + printf("%s :\n", tiut[i]->ville); while(tiut[i]->idDept != NULL) { printf("|%s|\n",tiut[i]->idDept->departement); @@ -233,8 +236,7 @@ void AffichageNbplaceDept(VilleIUT **tiut, int nbEle) int pos; for (pos = 0; pos < nbEle; pos++) { - AffichageVille(tiut[pos]->ville); - printf(" -> \t"); + printf("%s -> \t", tiut[pos]->ville); while(tiut[pos]->idDept->suiv != NULL && pos < nbEle) { printf("|%s, %d places|\n\t",tiut[pos]->idDept->departement, tiut[pos]->idDept->nbPers); @@ -250,12 +252,12 @@ int rechVille(VilleIUT **tiut, int nbEle, char code[], int *trouve) while(inf <= sup) { m = (inf + sup)/2; - if (strcmp(tiut[r]->ville, code)==0) + if (strcmp(tiut[m]->ville, code)==0) { *trouve = 1; return m; } - if (strcmp(tiut[r]->ville, code)>0) + if (strcmp(tiut[m]->ville, code)>0) sup = m - 1; else inf = m + 1; } @@ -289,7 +291,10 @@ void AffichageNbplaceDeptVille(VilleIUT **tiut, int nbEle) break; } } - else printf("%s n'a pas d'IUT\n",code);; + if (trouve == 0) printf("%s n'a pas d'IUT\n",code); + printf("Saisi Département :\n"); + if(!verifSelection()) + break; } } @@ -330,7 +335,7 @@ void AffichageDeptVille(VilleIUT **tiut, int nbEle) aux = rechercheDept(tiut[pos]->idDept, code); if(aux != NULL) { - AffichageVille(tiut[pos]->ville); + printf("- %s\n", tiut[pos]->ville); nbocc = nbocc + 1; } } @@ -348,8 +353,7 @@ void AffichageGlobalIUT(VilleIUT **tiut, int nbEle) printf("Ville : \t"); while(pos < nbEle) { - AffichageVille(VilleIUT) - printf(" :\n\t"); + printf("-%s :\n\t", tiut[pos]->ville); printf("Département:\tNombre de places:\tNom du Responsable:\n\t"); affichageListeDept(tiut[pos]->idDept); pos = pos + 1; @@ -415,17 +419,17 @@ void creationDept(VilleIUT **tiut, int nbEle) { printf("Nom du Département : "); scanf("%s", code); - aux = rechercheDept(tiut[pos]->idDept, code) + aux = rechercheDept(tiut[pos]->idDept, code); if (aux != NULL) printf("Département déjà existant"); if (aux == NULL) { printf("Nom du Responsable du Département de %s : ",code); fgets(nom,30,stdin); - nom[strlen(nom)-1] = "\0"; + nom[strlen(nom)-1] = '\0'; printf("Nombre de place du Département %s : ",code); scanf("%d", nbP); - tiut[pos]->idDept = inserer(tiut[pos]->idDept,code,nom,nbP); + tiut[pos]->idDept = insererDept(tiut[pos]->idDept,code,nom,nbP); printf("insertion du département %s effectuer \n", code); } printf("Saisi Département :\n"); @@ -457,10 +461,10 @@ void suppressionDept(VilleIUT **tiut, int nbEle) { printf("Nom du Département : "); scanf("%s", code); - aux = rechercheDept(tiut[pos]->idDept, code) + aux = rechercheDept(tiut[pos]->idDept, code); if (aux != NULL) if (confirmationSup()) - tiut[pos]->idDept = supprimer(tiut[pos]->idDept, code); + tiut[pos]->idDept = supprimerDept(tiut[pos]->idDept, code); if (aux == NULL) printf("Ce Département n'existe pas dans l'IUT de %s \n",tiut[pos]->ville); printf("Saisi Département :\n"); @@ -497,7 +501,7 @@ void modifChefDept(VilleIUT **tiut, int nbEle) printf("Nom de l'ancien chef de département %s de %s : %s\n",aux->departement, tiut[pos]->ville,aux->responsable); printf("Nom du nouveau chef de département %s de %s :",aux->departement, tiut[pos]->ville); fgets(code,30,stdin); - code[strlen(code)-1] = "\0"; + code[strlen(code)-1] = '\0'; strcpy(code, aux->responsable); printf("Chef de département : %s\n",tiut[pos]->idDept->responsable); } @@ -522,15 +526,15 @@ void triEchange(VilleIUT **tiut, int nbEle) while(nbEle>1) { pge = plusGrand(tiut, nbEle); - echanger(tiut,pge,nb-1); - nb = nb - 1; + echanger(tiut,pge,nbEle-1); + nbEle = nbEle - 1; } } int plusGrand(VilleIUT **tiut, int nbEle) { int pge = 0, i; - for (i = 1, i < nb, i++) + for (i = 1; i < nbEle; i++) if (strcmp(tiut[i]->ville,tiut[pge]->ville)>0) pge = 1; return pge; @@ -550,7 +554,4 @@ void clearpage(void) printf("\nappuyé sur la touche [ENTREE] pour continuer"); scanf("%*c%c", &entre); system("clear"); -} - - - +} \ No newline at end of file