parent
fd0e1c999d
commit
dd46d261ab
@ -0,0 +1,77 @@
|
||||
/*!
|
||||
\file deux.c
|
||||
\author GOIGOUX Lucie & JEUDI--LEMOINE Alix
|
||||
\date 23/12/22
|
||||
\brief Partie 2 de la SAE 1.02
|
||||
|
||||
Application de gestion des candidature dans les IUT de France
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "deux.h"
|
||||
|
||||
|
||||
Candidat* creerCandidat(void) {
|
||||
return (Candidat*) malloc(sizeof(Candidat));
|
||||
}
|
||||
|
||||
void afficherCandidat(Candidat* candidat) {
|
||||
printf("Candidat '%s %s' :"
|
||||
"\n - Moyenne en mathématiques : %f\n - Moyenne en français : %f"
|
||||
"\n - Moyenne en anglais : %f\n - Moyenne en spécialité : %f\n\n",
|
||||
candidat->prenom, candidat->nom,
|
||||
candidat->moyenneMath, candidat->moyenneFrancais,
|
||||
candidat->moyenneAnglais, candidat->moyenneSpecialite);
|
||||
}
|
||||
|
||||
ListeCandidats lireCandidats(int* nbCandidats) {
|
||||
FILE *fe = fopen("donnees/candidats.don", "r");
|
||||
|
||||
if(fe == NULL) {
|
||||
fprintf(stderr, "Erreur: impossible de lire le fichier candidats.don");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fscanf(fe, "%d", nbCandidats);
|
||||
|
||||
ListeCandidats liste = (ListeCandidats) malloc(*nbCandidats*sizeof(Candidat));
|
||||
|
||||
for(int i=0; i<*nbCandidats; i++) {
|
||||
Candidat* candidat = creerCandidat();
|
||||
fscanf(fe, "%*d\n%[^\n]\n%[^\n]\n%f\n%f\n%f\n%f\n%d",
|
||||
candidat->nom, candidat->prenom,
|
||||
&candidat->moyenneMath, &candidat->moyenneFrancais,
|
||||
&candidat->moyenneAnglais, &candidat->moyenneSpecialite,
|
||||
&candidat->nbCandidatures);
|
||||
|
||||
ListeCandidatures listeCandidatures = (ListeCandidatures) malloc(candidat->nbCandidatures*sizeof(Candidature*));
|
||||
candidat->listeCandidatures = listeCandidatures;
|
||||
|
||||
for(int j=0; j<candidat->nbCandidatures; j++) {
|
||||
Candidature* candidature = (Candidature*) malloc(sizeof(Candidature));
|
||||
fscanf(fe, "\n%[^\n]\n%[^\n]\n%d%d",
|
||||
candidature->ville, candidature->departement,
|
||||
&candidature->decision, &candidature->validation);
|
||||
candidat->listeCandidatures[j] = candidature;
|
||||
}
|
||||
|
||||
liste[i] = candidat;
|
||||
}
|
||||
|
||||
return liste;
|
||||
}
|
||||
|
||||
int sauvegarderCandidats(ListeCandidats liste) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void test2(void) {
|
||||
int nbCandidats;
|
||||
//printf("pa kc");
|
||||
ListeCandidats liste = lireCandidats(&nbCandidats);
|
||||
|
||||
afficherCandidat(liste[0]);
|
||||
afficherCandidat(liste[1]);
|
||||
}
|
Loading…
Reference in new issue