diff --git a/Partie_2/exe b/Partie_2/exe new file mode 100755 index 0000000..04991b4 Binary files /dev/null and b/Partie_2/exe differ diff --git a/Partie_2/partie2.c b/Partie_2/partie2.c index 4704e2c..f9c005a 100644 --- a/Partie_2/partie2.c +++ b/Partie_2/partie2.c @@ -1,19 +1,56 @@ #include "prototype.h" -Liste inscription(Liste lCand, int nbInsc) +Liste listenouv(void) { - Candidat c; - printf("Veuillez rentrer votre nom et prénom : "); - scanf("%s%*c%s", c.nom, c.prenom); - printf("Entrez les notes : "); - scanf("%f %f %f %f", c.lNote[0], c.lNote[1], c.lNote[2], c.lNote[3]); - c.nbChoix=0; - c.lChoix=NULL; - c.numC=nbInsc + 1 + return NULL; +} + +bool vide(Liste l) +{ + return l==NULL; +} + +Liste inserer(Liste l, Candidat can) +{ + Maillon *m; + m=(Maillon*)malloc(sizeof(Maillon)); + if (vide(m)) + { + printf("Pb malloc\n"); + exit(1); + } + m->c=&can; + m->suiv=l; + m->h=m->h+1; + return m; } -void affichage(Liste l) +void affichageT(Liste l) +/*affiche la liste de tous les candidats*/ { - printf("Numéro \t Prénom \t Nom \t Notes \t Nombre voeux \t Voeux\n"); - + printf("Numéro \tPrénom \tNom\n"); + affichage1(*l->c); +} + +void affichage1(Candidat c) +/*affiche les informations d'un candidat*/ +{ + printf("%d \t%s\n", c.numC, c.prenom); +} + +Liste inscription(Liste lCand, int nbInsc) +/* inscript un candidat en rentrant toutes ses informations*/ +{ + Candidat c; + printf("Veuillez rentrer votre prénom : "); + scanf("%s", c.prenom); + printf("%s\n", c.prenom); + printf("Veuillez rentrer votre nom : "); + scanf("%s", c.nom); + printf("%s\n", c.nom); + c.nbChoix=0; + c.lChoix=NULL; + c.numC=nbInsc + 1; + lCand=inserer(lCand, c); + return lCand; } \ No newline at end of file diff --git a/Partie_2/prototype.h b/Partie_2/prototype.h index 43bdb82..d00c749 100644 --- a/Partie_2/prototype.h +++ b/Partie_2/prototype.h @@ -3,6 +3,14 @@ #include #include +typedef struct + { + char ville; + char dpt; + int chDpt; + int chCand; + } Choix; + typedef struct { int numC; @@ -10,27 +18,25 @@ typedef struct char nom[20]; float lNote[4]; int nbChoix; - struct Choix lChoix[nbChoix]; + Choix *lChoix; } Candidat; -typedef struct - { - char ville; - char dpt; - int chDpt; - int chCand; - } Choix; - typedef struct maillon { - struct Candidat c; + Candidat *c; struct maillon *suiv; + int h; } Maillon, *Liste; +/*Implémentation liste*/ +Liste listenouv(void); +void affichageT(Liste l); +void affichage1(Candidat c); +void global(void); + +/*Reste*/ Liste inscription(Liste lCand, int nbInsc); Liste candidater(Liste lCand, Candidat c); Liste modifier(Liste lCand, Candidat c); Liste supprimer(Liste lCand, Candidat c); -void sauvegarder(Liste l); -void affichage(Liste l); -void global(void); \ No newline at end of file +void sauvegarder(Liste l); \ No newline at end of file diff --git a/Partie_2/test.c b/Partie_2/test.c index fc96c09..54b1a22 100644 --- a/Partie_2/test.c +++ b/Partie_2/test.c @@ -4,10 +4,13 @@ void testInsc(void) { Liste l; int nb=0; + l=listenouv(); l=inscription(l, nb); + affichageT(l); } int main(void) { + testInsc(); return 1; } \ No newline at end of file