#include "SAE.h" /* Partie 2 */ /* Afficher les infos d'un candidat Afficher la liste des candidats par departement trié par ordre alphabetique */ int rechercheCandidat(Etudiant *tetud[], int nbCandidats, int numRecherche, bool *trouve) { int i; for (i = 0; i < nbCandidats; i++) { if (numRecherche == tetud[i]->num) { *trouve = true; return i; } } *trouve = false; return i; } void afficherEtudiant(Etudiant mEtudiant) { // TODO : Changer l'affichage int i; printf("%d\n%s\n%s\n%.2f\t%.2f\t%.2f\t%.2f\n%d\n", mEtudiant.num, mEtudiant.nom, mEtudiant.prenom, mEtudiant.tabMatiere[0], mEtudiant.tabMatiere[1], mEtudiant.tabMatiere[2], mEtudiant.tabMatiere[3], mEtudiant.nbChoix); afficherChoix(mEtudiant.lChoix); printf("\n"); } void afficherCandidat(Etudiant *tetud[], int nbCandidats) { int num, index; bool trouve; printf("Veuillez entrer le numéro de l'étudiant recherché :\n> "); scanf("%d", &num); index = rechercheCandidat(tetud, nbCandidats, num, &trouve); if (trouve == false) { printf("Le numéro de l'étudiant recherché n'existe pas.\n"); return; } afficherEtudiant(*tetud[index]); } void afficherCandidats(Etudiant *tetud[], int nbCandidats) { for (int i = 0; i < nbCandidats; i++) { afficherEtudiant(*tetud[i]); } } int chargerCandidats(Etudiant *tetud[]) { 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); } fscanf(file, "%d", &nbCandidats); while (i < nbCandidats) { tetud[i] = (Etudiant *)malloc(sizeof(Etudiant)); if (tetud[i] == NULL) { printf("Erreur malloc"); exit(2); } fscanf(file, "%d%s%s", &tetud[i]->num, tetud[i]->nom, tetud[i]->prenom); // TODO : Faire un fgets pour le prénom for (int note = 0; note < 4; note++) { fscanf(file, "%f", &tetud[i]->tabMatiere[note]); } fscanf(file, "%d", &tetud[i]->nbChoix); tetud[i]->lChoix = listenouvChoix(); for (int n = 0; n < tetud[i]->nbChoix; n++) { fscanf(file, "%s%s%d%d", choix.ville, choix.departement, &choix.decisionAdmission, &choix.decisionCandidat); tetud[i]->lChoix = insererChoix(tetud[i]->lChoix, choix); } i++; } return i; } void sauvegarderCandidats(Etudiant *tetud[], int nbCandidats) { FILE *file; file = fopen("resultats.txt", "w"); if (file == NULL) { printf("Erreur d'ouverture du fichier !\n"); exit(1); } fprintf(file, "%d\n", nbCandidats); for (int i = 0; i < nbCandidats; i++) { fprintf(file, "%d\n%s\n%s\n", tetud[i]->num, tetud[i]->nom, tetud[i]->prenom); for (int note = 0; note < 4; note++) { fprintf(file, "%.2f\t", tetud[i]->tabMatiere[note]); } fprintf(file, "\n%d\n", tetud[i]->nbChoix); sauvegarderChoix(tetud[i]->lChoix, file); } } void sauvegarderChoix(ListeChoix lChoix, FILE *file) { if (lChoix != NULL) { fprintf(file, "%s\n%s\n%d\n%d\n", lChoix->choix.ville, lChoix->choix.departement, lChoix->choix.decisionAdmission, lChoix->choix.decisionCandidat); sauvegarderChoix(lChoix->suiv, file); } } // 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; // } // } // void afficherCandidatsNonAdmis(ListeAdmission la) // { // while (!videCand(la->v.ldept)) // { // if (la->v.ldept->v.decisionAdmission == 0) // { // afficherCandidats(la); // } // } // } // 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; // } // } // 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; // }