diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..136d521 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: gcc générer le fichier actif", + "command": "/usr/bin/gcc", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}/${fileBasenameNoExtension}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Tâche générée par le débogueur." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/Autres/genere b/Autres/genere new file mode 100755 index 0000000..3037d9e Binary files /dev/null and b/Autres/genere differ diff --git a/Autres/genere.c b/Autres/genere.c new file mode 100644 index 0000000..9c6a717 --- /dev/null +++ b/Autres/genere.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include + +int main(int argc, char** argv) { + // Ouverture du fichier en mode écriture + FILE* f = fopen("resultats.txt", "w"); + if (f == NULL) { + printf("Error opening file!\n"); + exit(1); + } + + // Initialisation du générateur de nombres aléatoires + srand(time(0)); + + // Écriture des en-têtes de colonnes + fprintf(f, "Numero de candidat\tNom\tPrenom\tNote de maths\tNote de francais\tNote d'anglais\tNote de specialite\tNombre de choix de candidatures\tVille choisie de la premiere candidature\tDepartement\tDecision du departement\tValidation\n"); + + // Génération de données aléatoires pour chaque candidat + for (int i = 1; i <= 100; i++) { + char nom[21]; + for (int j = 0; j < 20; j++) { + nom[j] = rand() % 26 + 'a'; + } + nom[0] = toupper(nom[0]); + char prenom[21]; + for (int j = 0; j < 20; j++) { + prenom[j] = rand() % 26 + 'a'; + } + char note_maths[3]; + sprintf(note_maths, "%d", rand() % 21); + char note_francais[3]; + sprintf(note_francais, "%d", rand() % 21); + char note_anglais[3]; + sprintf(note_anglais, "%d", rand() % 21); + char note_specialite[3]; + sprintf(note_specialite, "%d", rand() % 21); + char nb_choix[2]; + sprintf(nb_choix, "%d", rand() % 6); + char ville[] = "Clermont-Ferrand"; + char departement1[14]; + sprintf(departement1, "Departement%d", rand() % 21); + char departement2[14]; + sprintf(departement2, "Departement%d", rand() % 21); + char departement3[14]; + sprintf(departement3, "Departement%d", rand() % 21); + char departement4[14]; + sprintf(departement4, "Departement%d", rand() % 21); + char departement5[14]; + sprintf(departement5, "Departement%d", rand() % 21); + char decision[] = "0"; + char validation[] = "0"; + + } +} diff --git a/Autres/resultats.txt b/Autres/resultats.txt new file mode 100644 index 0000000..afa6075 --- /dev/null +++ b/Autres/resultats.txt @@ -0,0 +1 @@ +Numero de candidat Nom Prenom Note de maths Note de francais Note d'anglais Note de specialite Nombre de choix de candidatures Ville choisie de la premiere candidature Departement Decision du departement Validation diff --git a/SAE.h b/SAE.h index b7e065a..03bf3ad 100755 --- a/SAE.h +++ b/SAE.h @@ -48,17 +48,19 @@ void modificationRespDept(VilleIUT *tiut[], int nb); // Partie 3 -Departement lireDpt(FILE *flot, ListeDepartement dpt); -void afficheDept(Departement dpt); -Admission lireCandidat(FILE *flot, ListeAdmission la); -void afficherCandidat(Admission candidat); -int chargerCandidats(MaillonEtudiant *tetud[]); -void sauvegarderCandidats(ListeAdmission listeCandidats, char dptResAdmi[30]); -void afficherCandidatsAdmis(ListeAdmission listeCandidats); -void afficherCandidatsNonAdmis(ListeAdmission listeCandidats); -void afficherCandidatsAttente(ListeAdmission listeCandidats); -void afficherCandidatsDpt(ListeAdmission listeCandidats); -ListeAdmission MoyenneCandidats(ListeAdmission listeCandidats); +void afficherEtudiant(Etudiant mEtudiant); + +// Admission lireCandidat(FILE *flot, ListeAdmission la); +// Departement lireDpt(FILE *flot, ListeDepartement dpt); +// void afficheDept(Departement dpt); +// void afficherCandidat(Admission candidat); +// int chargerCandidats(Etudiant *tetud[]); +// void sauvegarderCandidats(ListeAdmission listeCandidats, char dptResAdmi[30]); +// void afficherCandidatsAdmis(ListeAdmission listeCandidats); +// void afficherCandidatsNonAdmis(ListeAdmission listeCandidats); +// void afficherCandidatsAttente(ListeAdmission listeCandidats); +// void afficherCandidatsDpt(ListeAdmission listeCandidats); +// ListeAdmission MoyenneCandidats(ListeAdmission listeCandidats); // Liste Choix ListeChoix listenouvChoix(void); diff --git a/exe b/exe new file mode 100755 index 0000000..4e92df5 Binary files /dev/null and b/exe differ diff --git a/partie_3.c b/partie_3.c index aa4e7fc..e609b2b 100755 --- a/partie_3.c +++ b/partie_3.c @@ -1,17 +1,13 @@ #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; -// } - -// 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[]) +/* Partie 2 */ +/* + Afficher les infos d'un candidat + + Afficher la liste des candidats par departement trié par ordre alphabetique +*/ + +// Etudiant lireCandidat(FILE *flot, MaillonChoix mChoix, char dptResAdmis[]) // { // int i = 0; // fscanf(flot, "%d\n", &la->v.num); @@ -38,58 +34,67 @@ // return la->v; // } -// void afficherCandidats(ListeAdmission la) +// Departement lireDept(FILE *flot, ListeDepartement dpt) // { -// 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"); +// 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); // } -// Regarder si le nombre de choix est = à 0 Que se passe-t-il ? -int chargerCandidats(MaillonEtudiant *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(!feof(file)) - { - tetud[i] = (MaillonEtudiant*)malloc(sizeof(MaillonEtudiant)); - if (tetud[i]==NULL) - { - printf("Erreur malloc"); - exit(2); - } - 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++) - { - 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); - } - } +void afficherEtudiant(Etudiant mEtudiant) +{ + int i; + printf("%d\t%s\t%s\t%.2f\t%.2f\t%.2f\t%.2f\t%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"); } +// Regarder si le nombre de choix est = à 0 Que se passe-t-il ? + +// 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(!feof(file)) +// { +// tetud[i] = (Etudiant*)malloc(sizeof(Etudiant)); +// if (tetud[i]==NULL) +// { +// printf("Erreur malloc"); +// exit(2); +// } +// 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++) +// { +// 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); +// } +// } + +// } + // void sauvegarderCandidats(ListeAdmission la, char dptResAdmi[30]) // { // FILE *flot; diff --git a/structures.c b/structures.c index ea30cc1..055e81d 100755 --- a/structures.c +++ b/structures.c @@ -116,5 +116,5 @@ int longueurChoix(ListeChoix lc) void afficherCandidatsChoix(Choix choix) { - printf("Ville : %s\nDépartement : %s\nAdmission : %d\nCandidat : %d\n", choix.ville, choix.departement, choix.decisionAdmission, choix.decisionCandidat); + printf("Ville : %s\nDépartement : %s\nAdmission : %d\nCandidat : %d\n", choix.ville, choix.departement, choix.decisionAdmission, choix.decisionCandidat); } \ No newline at end of file diff --git a/structures.h b/structures.h index 65d5c17..875f0f4 100644 --- a/structures.h +++ b/structures.h @@ -41,4 +41,4 @@ typedef struct float tabMatiere[5]; int nbChoix; ListeChoix lChoix; -} MaillonEtudiant; +} Etudiant;