diff --git a/SAE.h b/SAE.h index 7b1e09f..da66b4c 100755 --- a/SAE.h +++ b/SAE.h @@ -52,7 +52,7 @@ Departement lireDpt(FILE *flot, ListeDepartement dpt); void afficheDept(Departement dpt); Admission lireCandidat(FILE *flot, ListeAdmission la); void afficherCandidat(Admission candidat); -ListeAdmission chargerCandidats(char *ficAdmission, char dptResAdmi[30], ListeAdmission la); +int chargerCandidats(MaillonEtudiant *tetud[]); void sauvegarderCandidats(ListeAdmission listeCandidats, char dptResAdmi[30]); void afficherCandidatsAdmis(ListeAdmission listeCandidats); void afficherCandidatsNonAdmis(ListeAdmission listeCandidats); diff --git a/administrateur.c b/administrateur.c index bd19b7e..9e2d616 100644 --- a/administrateur.c +++ b/administrateur.c @@ -60,7 +60,7 @@ void creationDept(VilleIUT *tiut[], int nb) int suppressionDept(VilleIUT *tiut[], int nb) { char nomDept[30], iut[30], choix; - int posIUT, posDept; + int posIUT; bool trouve; printf("Dans quel IUT voulez-vous supprimer un département ?\n> "); scanf("%s", iut); @@ -72,7 +72,7 @@ int suppressionDept(VilleIUT *tiut[], int nb) } printf("Quel département voulez-vous supprimer ?\n> "); scanf("%s", nomDept); - posDept = rechercheDept(tiut[posIUT]->ldept, nomDept, &trouve); + rechercheDept(tiut[posIUT]->ldept, nomDept, &trouve); if (trouve == false) { printf("Ce département n'existe pas dans cet IUT. Veuillez réessayer.\n"); diff --git a/exe b/exe deleted file mode 100755 index 379b279..0000000 Binary files a/exe and /dev/null differ diff --git a/partie1.c b/partie1.c index abd2d58..af7f2e0 100755 --- a/partie1.c +++ b/partie1.c @@ -67,7 +67,7 @@ int rechercheVille(VilleIUT *tiut[], int nb, char val[], bool *trouve) void sauvegardeVillesIUT(VilleIUT *tiut[], int nb) { char ville[30], dept[30], resp[30]; - int nbP, posDept; + int nbP; FILE *file = fopen("informationsIUT.txt", "w"); if (file == NULL) { diff --git a/partie_3.c b/partie_3.c index 6d38682..aa4e7fc 100755 --- a/partie_3.c +++ b/partie_3.c @@ -1,208 +1,226 @@ #include "SAE.h" -Departement lireDept(FILE *flot, ListeDepartement dpt) -{ - fscanf(flot, "%s\n%d\n%d\n", dpt.departement, &dpt.decisionAdmission, &dpt.decisionCandidat); - return dpt; -} +// Departement lireDept(FILE *flot, ListeDepartement dpt) +// { +// fscanf(flot, "%s\n%d\n%d\n", dpt.departement, &dpt.decisionAdmission, &dpt.decisionCandidat); +// return dpt; +// } -void afficheDept(Departement dpt) -{ - printf("\t%s\t%d\t%d", dpt.departement, dpt.decisionAdmission, dpt.decisionCandidat); -} +// void afficheDept(Departement dpt) +// { +// printf("\t%s\t%d\t%d", dpt.departement, dpt.decisionAdmission, dpt.decisionCandidat); +// } -Admission lireCandidat(FILE *flot, ListeAdmission la, char dptResAdmis[]) -{ - int i = 0; - fscanf(flot, "%d\n", &la->v.num); - fgets(la->v.nom, 22, flot); - la->v.nom[strlen(la->v.nom) - 1] = '\0'; - fgets(la->v.prenom, 22, flot); - la->v.prenom[strlen(la->v.prenom) - 1] = '\0'; - fscanf(flot, "%d\t%d\t%d\t%d\n%d\n%s\n", &la->v.tabMatiere[0], &la->v.tabMatiere[1], &la->v.tabMatiere[2], &la->v.tabMatiere[3], &la->v.nbChoix, la->v.ville); - if (la->v.nbChoix == 0) - { - listenouv(); - return la->v; - } - ajouterDpt(la->v.ldept, lireDept(flot, la->v.ldept)); - while (!feof(flot) && i < la->v.nbChoix) - { - if (strcmp(la->v.ldept, dptResAdmi) == 0) - { - la->v.ldept = insererDpt(la->v.ldept, la->v.ldept->v.departement); - } - ajouterDpt(la->v.ldept, lireDept(flot, la->v.ldept)); - i++; - } - return la->v; -} +// Admission lireCandidat(FILE *flot, ListeAdmission la, char dptResAdmis[]) +// { +// int i = 0; +// fscanf(flot, "%d\n", &la->v.num); +// fgets(la->v.nom, 22, flot); +// la->v.nom[strlen(la->v.nom) - 1] = '\0'; +// fgets(la->v.prenom, 22, flot); +// la->v.prenom[strlen(la->v.prenom) - 1] = '\0'; +// fscanf(flot, "%d\t%d\t%d\t%d\n%d\n%s\n", &la->v.tabMatiere[0], &la->v.tabMatiere[1], &la->v.tabMatiere[2], &la->v.tabMatiere[3], &la->v.nbChoix, la->v.ville); +// if (la->v.nbChoix == 0) +// { +// listenouv(); +// return la->v; +// } +// ajouterDpt(la->v.ldept, lireDept(flot, la->v.ldept)); +// while (!feof(flot) && i < la->v.nbChoix) +// { +// if (strcmp(la->v.ldept, dptResAdmi) == 0) +// { +// la->v.ldept = insererDpt(la->v.ldept, la->v.ldept->v.departement); +// } +// ajouterDpt(la->v.ldept, lireDept(flot, la->v.ldept)); +// i++; +// } +// return la->v; +// } -void afficherCandidats(ListeAdmission la) -{ - int i; - printf("%d\t%s\t%s\t%d\t%d\t%d\t%d\t%d\t%s\t%s\t%d\t%d", la->v.num, la->v.nom, la->v.prenom, la->v.tabMatiere[0], la->v.tabMatiere[1], la->v.tabMatiere[2], la->v.tabMatiere[3], la->v.nbChoix, la->v.ville); - for (i = 0; i < la->v.nbChoix; i++) - { - afficherDpt(la->v.ldept->v); - la->v.ldept = la->v.ldept->suiv; - } - printf("\n"); -} +// void afficherCandidats(ListeAdmission la) +// { +// int i; +// printf("%d\t%s\t%s\t%d\t%d\t%d\t%d\t%d\t%s\t%s\t%d\t%d", la->v.num, la->v.nom, la->v.prenom, la->v.tabMatiere[0], la->v.tabMatiere[1], la->v.tabMatiere[2], la->v.tabMatiere[3], la->v.nbChoix, la->v.ville); +// for (i = 0; i < la->v.nbChoix; i++) +// { +// afficherDpt(la->v.ldept->v); +// la->v.ldept = la->v.ldept->suiv; +// } +// printf("\n"); +// } // Regarder si le nombre de choix est = à 0 Que se passe-t-il ? -ListeAdmission chargerCandidats(char *ficAdmission, char dptResAdmi[30], ListeAdmission la) +int chargerCandidats(MaillonEtudiant *tetud[]) { - FILE *flot; - listenouv(); - flot = fopen(ficAdmission, "r"); - if (flot == NULL) + FILE *file; + file = fopen("resultats.txt", "r"); + int nbCandidats, i = 0; + Choix choix; + if (file == NULL) { printf("Erreur d'ouverture du fichier !\n"); exit(1); } - insererAdm(la, lireCandidat(flot, la, dptResAdmi)); - while (!feof(flot)) + fscanf(file, "%d", &nbCandidats); + while(!feof(file)) { - la = insererCand(la, la->v); - la->v = lireCandidat(flot, la, dptResAdmi); - } - fclose(flot); - return la; -} - -void sauvegarderCandidats(ListeAdmission la, char dptResAdmi[30]) -{ - FILE *flot; - flot = fopen("admissionInfo.txt", "w"); - if (flot == NULL) - { - printf("Erreur d'ouverture du fichier !\n"); - exit(1); - } - while (!videAdm(la)) - { - fprintf(flot, "%d\n%s\n%s\n%d\t%d\t%d\t%d\n%d\n%s\n", la->v.num, la->v.nom, la->v.prenom, la->v.tabMatiere[0], la->v.tabMatiere[1], la->v.tabMatiere[2], la->v.tabMatiere[3], la->v.nbChoix, la->v.ville); - while (!videDpt(la->v.ldept)) + tetud[i] = (MaillonEtudiant*)malloc(sizeof(MaillonEtudiant)); + if (tetud[i]==NULL) { - fprintf(flot, "%s\n%d\n%d\n", la->v.ldept->v.departement, la->v.ldept->v.decisionAdmission, la->v.ldept->v.decisionCandidat); - la->v.ldept = la->v.ldept->suiv; + printf("Erreur malloc"); + exit(2); } - la = la->suiv; - } - fclose(flot); -} - -void afficherCandidatsAdmis(ListeAdmission la) -{ - while (!videCand(la->v.ldept)) - { - if (la->v.ldept->v.decisionAdmission == 1) + fscanf("%d%s", tetud[i]->num, tetud[i]->nom); + fgets(tetud[i]->prenom, 22, stdin); + tetud[i]->prenom[strlen(tetud[i]->prenom - 1)] = '\0'; + for (int note = 0; note < 5; note++) { - afficherCandidats(la); + fscanf(file, "%f", tetud[i]->tabMatiere[note]); } - la->v.ldept = la->v.ldept->suiv; - } -} - -void afficherCandidatsNonAdmis(ListeAdmission la) -{ - while (!videCand(la->v.ldept)) - { - if (la->v.ldept->v.decisionAdmission == 0) + fscanf(file, "%d", tetud[i]->nbChoix); + tetud[i]->lChoix = listenouvChoix(); + for (int n = 0; n < tetud[i]->nbChoix; n++) { - afficherCandidats(la); + fscanf(file, "%s%s%d%d", choix.ville, choix.departement, &choix.decisionAdmission, &choix.decisionCandidat); + tetud[i]->lChoix = insererChoix(tetud[i]->lChoix, choix); } } -} -void afficherCandidatsAttente(ListeAdmission la) -{ - while (!videCand(la->v.ldept)) - { - if (la->v.ldept->v.decisionAdmission == 2) - { - afficherCandidats(la); - } - la = la->suiv; - } } -void afficherCandidatsDpt(ListeAdmission la) -{ - while (!videAdm(la->v.ldept)) - { - afficherCandidats(la); - la = la->suiv; - } -} +// void sauvegarderCandidats(ListeAdmission la, char dptResAdmi[30]) +// { +// FILE *flot; +// flot = fopen("admissionInfo.txt", "w"); +// if (flot == NULL) +// { +// printf("Erreur d'ouverture du fichier !\n"); +// exit(1); +// } +// while (!videAdm(la)) +// { +// fprintf(flot, "%d\n%s\n%s\n%d\t%d\t%d\t%d\n%d\n%s\n", la->v.num, la->v.nom, la->v.prenom, la->v.tabMatiere[0], la->v.tabMatiere[1], la->v.tabMatiere[2], la->v.tabMatiere[3], la->v.nbChoix, la->v.ville); +// while (!videDpt(la->v.ldept)) +// { +// fprintf(flot, "%s\n%d\n%d\n", la->v.ldept->v.departement, la->v.ldept->v.decisionAdmission, la->v.ldept->v.decisionCandidat); +// la->v.ldept = la->v.ldept->suiv; +// } +// la = la->suiv; +// } +// fclose(flot); +// } -ListeAdmission MoyenneCandidats(ListeAdmission la) -{ - while (!videAdm(la)) - { - la->v.tabMatiere[4] = (la->v.tabMatiere[0] + la->v.tabMatiere[1] + la->v.tabMatiere[2] + la->v.tabMatiere[3]) / 4; - la = la->suiv; - } - return la; -} +// void afficherCandidatsAdmis(ListeAdmission la) +// { +// while (!videCand(la->v.ldept)) +// { +// if (la->v.ldept->v.decisionAdmission == 1) +// { +// afficherCandidats(la); +// } +// la->v.ldept = la->v.ldept->suiv; +// } +// } -// Comment definir la note sur 20 mise lors de l'etude du dossier ? -// Ajouter une variable dans la structure Admission ? -// Ou mettre la liste et la note dans un tableau ? -// Après examen de chaque dossier de candidature, -// le jury doit regarder ou la note peut etre calculée automatiquement ? +// void afficherCandidatsNonAdmis(ListeAdmission la) +// { +// while (!videCand(la->v.ldept)) +// { +// if (la->v.ldept->v.decisionAdmission == 0) +// { +// afficherCandidats(la); +// } +// } +// } -int modifNoteMinAdmis() -{ - int noteMaths, noteFrançais, noteAnglais, noteSpe; - printf("Entrez la nouvelle note minimale d'admission en maths (-1 pour quitter) : "); - while (noteMaths < 0 || noteMaths > 20) - { - scanf("%d", ¬eMaths); - if (noteMaths == -1) - { - break; - } - printf("La note doit être comprise entre 0 et 20 !\n"); - } - printf("Entrez la nouvelle note minimale d'admission en français (-1 pour quitter) : "); - while (noteFrançais < 0 || noteFrançais > 20) - { - scanf("%d", ¬eFrançais); - if (noteFrançais == -1) - { - break; - } - printf("La note doit être comprise entre 0 et 20 !\n"); - } - printf("Entrez la nouvelle note minimale d'admission en anglais (-1 pour quitter) : "); - while (noteAnglais < 0 || noteAnglais > 20) - { - scanf("%d", ¬eAnglais); - if (noteAnglais == -1) - { - break; - } - printf("La note doit être comprise entre 0 et 20 !\n"); - } - printf("Entrez la nouvelle note minimale d'admission en spécialité (-1 pour quitter) : "); - while (noteSpe < 0 || noteSpe > 20) - { - scanf("%d", ¬eSpe); - if (noteSpe == -1) - { - break; - } - printf("La note doit être comprise entre 0 et 20 !\n"); - } -} +// void afficherCandidatsAttente(ListeAdmission la) +// { +// while (!videCand(la->v.ldept)) +// { +// if (la->v.ldept->v.decisionAdmission == 2) +// { +// afficherCandidats(la); +// } +// la = la->suiv; +// } +// } -int modifNbAdmisMax() -{ - int nbAdmisMax; - printf("Entrez le nouveau nombre d'admis maximum : "); - scanf("%d", &nbAdmisMax); - return nbAdmisMax; -} +// void afficherCandidatsDpt(ListeAdmission la) +// { +// while (!videAdm(la->v.ldept)) +// { +// afficherCandidats(la); +// la = la->suiv; +// } +// } + +// ListeAdmission MoyenneCandidats(ListeAdmission la) +// { +// while (!videAdm(la)) +// { +// la->v.tabMatiere[4] = (la->v.tabMatiere[0] + la->v.tabMatiere[1] + la->v.tabMatiere[2] + la->v.tabMatiere[3]) / 4; +// la = la->suiv; +// } +// return la; +// } + +// // Comment definir la note sur 20 mise lors de l'etude du dossier ? +// // Ajouter une variable dans la structure Admission ? +// // Ou mettre la liste et la note dans un tableau ? +// // Après examen de chaque dossier de candidature, +// // le jury doit regarder ou la note peut etre calculée automatiquement ? + +// int modifNoteMinAdmis() +// { +// int noteMaths, noteFrançais, noteAnglais, noteSpe; +// printf("Entrez la nouvelle note minimale d'admission en maths (-1 pour quitter) : "); +// while (noteMaths < 0 || noteMaths > 20) +// { +// scanf("%d", ¬eMaths); +// if (noteMaths == -1) +// { +// break; +// } +// printf("La note doit être comprise entre 0 et 20 !\n"); +// } +// printf("Entrez la nouvelle note minimale d'admission en français (-1 pour quitter) : "); +// while (noteFrançais < 0 || noteFrançais > 20) +// { +// scanf("%d", ¬eFrançais); +// if (noteFrançais == -1) +// { +// break; +// } +// printf("La note doit être comprise entre 0 et 20 !\n"); +// } +// printf("Entrez la nouvelle note minimale d'admission en anglais (-1 pour quitter) : "); +// while (noteAnglais < 0 || noteAnglais > 20) +// { +// scanf("%d", ¬eAnglais); +// if (noteAnglais == -1) +// { +// break; +// } +// printf("La note doit être comprise entre 0 et 20 !\n"); +// } +// printf("Entrez la nouvelle note minimale d'admission en spécialité (-1 pour quitter) : "); +// while (noteSpe < 0 || noteSpe > 20) +// { +// scanf("%d", ¬eSpe); +// if (noteSpe == -1) +// { +// break; +// } +// printf("La note doit être comprise entre 0 et 20 !\n"); +// } +// } + +// int modifNbAdmisMax() +// { +// int nbAdmisMax; +// printf("Entrez le nouveau nombre d'admis maximum : "); +// scanf("%d", &nbAdmisMax); +// return nbAdmisMax; +// } diff --git a/structures.h b/structures.h index f829bf8..65d5c17 100644 --- a/structures.h +++ b/structures.h @@ -38,7 +38,7 @@ typedef struct int num; char nom[22]; // 20 caractere + 1 espace + 1 caractere de fin de chaine char prenom[22]; // 20 caractere + 1 espace + 1 caractere de fin de chaine - float tabMatiere[4]; + float tabMatiere[5]; int nbChoix; ListeChoix lChoix; } MaillonEtudiant;