diff --git a/part2.c b/part2.c index 2f9083d..fb0dfc3 100644 --- a/part2.c +++ b/part2.c @@ -1,10 +1,10 @@ #include #include #include -#include "commun.h" +#include "part2.h" -##########################TABLEAU POINTEUR##################################################### +//##########################TABLEAU POINTEUR##################################################### Choix lirechx (void){//Fonction qui va lire les choix de la ville et du departement demandé par le candidat @@ -28,12 +28,12 @@ Choix lirechx (void){//Fonction qui va lire les choix de la ville et du departem Candidat lireCandidat(void)//fonction qui lit un candidat sur le clavier { Candidat c; - printf("Numéro de candidat :\n"); - scanf("%d%*c", &c.nEtu); printf("Nom du candidat :\n"); fgets(c.nom, 20, stdin); + c.nom[strlen(c.nom)-1]= '\0'; printf("Prénom du candidat :\n"); fgets(c.prenom, 20, stdin); + c.prenom[strlen(c.prenom)-1]= '\0'; printf("Moyenne de maths :\n"); scanf("%f", &c.moymat); printf("Moyenne de français :\n"); @@ -67,34 +67,108 @@ void AffC(Candidat c) } +Candidat lireFich1Cand (FILE * fe){ + Candidat cand; + fgets(cand.nom, 20, fe); + cand.nom[strlen(cand.nom)-1]= '\0'; -######################################### LISTES ########################################## + fgets(cand.prenom, 20, fe); + cand.prenom[strlen(cand.prenom)-1]= '\0'; + + fscanf(fe, "%f", &cand.moymat); + fscanf(fe, "%f", &cand.moyfr); + fscanf(fe, "%f", &cand.moyen); + fscanf(fe, "%f", &cand.moyspe); + fscanf(fe, "%d%*c", &cand.nbchx); + + return cand; +} + +//######################################### LISTES ########################################## -void AffListeCandidat (Liste l){ +void AffListeCandidat (Listecand l){ if ( l == NULL) return; AffC(l->cand); AffListeCandidat(l->suivcand); } -Liste recherche (Liste l, char *nom ){ +Listecand recherche (Listecand l, char *nom ){ if ( l == NULL ){ return l;} - if ( strcmp ( l->Candidat.nom, nom ) == 0) return l; - return recherche (l->suivant, nom ); + if ( strcmp ( l->cand.nom, nom ) == 0) return l; + return recherche (l->suivcand, nom ); +} + +Listecand InsertT(Listecand list, Candidat c)//Insert en tête de la liste +{ + Mailloncand *c1; + + c1 = (Mailloncand*)malloc(sizeof(Mailloncand)); + if (c1 == NULL){printf("pb malloc"); exit;} + strcpy(c1->cand.nom, c.nom); + strcpy(c1->cand.prenom, c.prenom); + c1->cand.moymat = c.moymat; + c1->cand.moyfr = c.moyfr; + c1->cand.moyen = c.moyen; + c1->cand.moyspe = c.moyspe; + c1->cand.nbchx = c.nbchx; + c1->suivcand = list; + return c1; + +} + + +Listecand Insert(Listecand list, Mailloncand * c)//insert globalement +{ + if (list == NULL){return InsertT(list, c);} + if (strcmp(list->departement, m->departement)>0){return InsertT(list, m);} + list->suiv = Insert(list->suiv, m); + return list; } +void test (void){ + int menu1, menugest1; + printf("Menu :\n");//Premier affichage menu pour choisir si on veut afficher le menu d'un candidat ou toutes les candidatures + printf("(1) Gestion Candidature\n(2) Affichage Candidature\n"); + scanf("%d", &menu1); + printf("%d", menu1); + while (menu1 != 1 && menu1 !=2){// Traitement des erreurs + printf("Erreur de saisie veuillez refaire votre choix ! \n"); + printf("(1) Gestion Candidature\n"); + printf("(2) Affichage Candidature\n"); + printf("(3) Quitter\n"); + scanf("%d", &menu1); + } + if (menu1 == 1){ + printf("Menu : \n");//Menu gestion ajout/modification/suppression d'une candidature + printf("(1) Ajouter une Candidature\n (2) Modifier une Candidature\n (3) Supprimer une Candidature"); + scanf("%d", &menugest1); + if (menugest1 == 1) + //FONCTION INSERTION LISTE AVEC AFFICHAGE NOUVELLE LISTE + //else if (menugest1 == 2) + //FONCTION MISE A JOUR LISTE AVEC AFFICHAGE NOUVELLE LISTE + //else if (menugest1 == 3) + //FONCTION SUPPRESSION LISTE AVEC AFFICHAGE NOUVELLE LISTE + + //} + //else if (menu1 == 2){ + printf(""); + + } + +} @@ -136,4 +210,4 @@ Liste recherche (Liste l, char *nom ){ -####################################### FILES ################################################# \ No newline at end of file +//####################################### FILES ################################################# \ No newline at end of file diff --git a/part2.don b/part2.don new file mode 100644 index 0000000..4ef487b --- /dev/null +++ b/part2.don @@ -0,0 +1,73 @@ +4 + +35 +Durand + +Jean Jacques + +15.75 12.25 9.5 17.00 + +3 + +Clermont-Ferrand +Informatique +0 +0 +Grenoble +Informatique +0 +0 +Aurillac +Bio-Informatique +0 +0 + +36 +Dupont + +Jeannine + +10.2 15.65 12.45 18.00 + +2 + +Clermont-Ferrand +Informatique +0 +0 +Aurillac +Informatique +0 +0 + +37 +Thérèse + +Francoise + +10.5 12.65 14.45 16.00 + +1 + +Clermont-Ferrand +Bio-Informatique +0 +0 + +38 +Henry + +Bertrand + +5.2 14.65 11.23 14.00 + +3 + +Clermont-Ferrand +Informatique +0 +0 +Aurillac +Informatique +0 +0 diff --git a/part2.h b/part2.h index 1347631..d8d3fd7 100644 --- a/part2.h +++ b/part2.h @@ -18,12 +18,12 @@ typedef struct { int valid;//validation du candidat }Choix; -typedef struct liste1{ +typedef struct Liste1{ Choix chx; - struct list1 * suivchx; -}Maillon1; + struct List1 * suivchx; +}Maillonchx; -typedef Maillon1 * list1; +typedef Maillonchx * Listechx; @@ -39,18 +39,21 @@ typedef struct { }Candidat; -typedef struct liste{ +typedef struct Liste{ Candidat cand; - struct liste * suivcand; -}Maillon; + struct Liste * suivcand; +}Mailloncand; -typedef Maillon * Liste; +typedef Mailloncand * Listecand; -Candidat lireCandidat(void); Choix lirechx (void); -void AffC(Candidat c); - +Candidat lireCandidat(void); +void AffC(Candidat c); +Candidat lireFich1Cand (FILE * fe); +void AffListeCandidat (Listecand l); +Listecand recherche (Listecand l, char *nom ); +void test (void); @@ -78,9 +81,5 @@ void AffC(Candidat c); -typedef struct liste { - Choix chx; - struct liste * suivant; -}Maillon; diff --git a/test b/test deleted file mode 100755 index f44aaa9..0000000 Binary files a/test and /dev/null differ diff --git a/tpart2.C b/tpart2.C deleted file mode 100644 index 23fdde6..0000000 --- a/tpart2.C +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include -#include -#include "commun.h" - - -int main(void) -{ - Candidat c; - c = lireCandidat(); - AffC(c); - Choix chx; - chx = lirechx(); - return 0; -} \ No newline at end of file diff --git a/tpart2.c b/tpart2.c new file mode 100644 index 0000000..b21cc82 --- /dev/null +++ b/tpart2.c @@ -0,0 +1,11 @@ +#include +#include +#include +#include "part2.h" + + +int main(void) +{ + test(); + return 0; +} \ No newline at end of file