diff --git a/SAE.h b/SAE.h index da66b4c..b7e065a 100755 --- a/SAE.h +++ b/SAE.h @@ -60,31 +60,18 @@ void afficherCandidatsAttente(ListeAdmission listeCandidats); void afficherCandidatsDpt(ListeAdmission listeCandidats); ListeAdmission MoyenneCandidats(ListeAdmission listeCandidats); -// Liste Admission -ListeAdmission listenouvAdm(void); -ListeAdmission insererEnTeteAdm(ListeAdmission la, Admission candidat); -ListeAdmission insererAdm(ListeAdmission la, Admission candidat); -void afficherAdm(ListeAdmission la); -bool videAdm(ListeAdmission la); -ListeAdmission supprimerEnTeteAdm(ListeAdmission la); -ListeAdmission supprimerAdm(ListeAdmission la, Admission candidat); -bool rechercheAdm(ListeAdmission la, Admission candidat); -Departement TeteAdm(ListeAdmission la); -int longueurAdm(ListeAdmission la); -void afficherCandidatsAdm(Admission candidat); - -// Liste Departement -ListeDepartement listenouvDpt(void); -ListeDepartement insererEnTeteDpt(ListeDepartement ld, Departement dpt); -ListeDepartement insererDpt(ListeDepartement ld, Departement dpt); -ListeDepartement supprimerEnTeteDpt(ListeDepartement ld); -ListeDepartement supprimerDpt(ListeDepartement ld, Departement dpt); -bool rechercheDpt(ListeDepartement ld, Departement dpt); -int TeteDpt(ListeDepartement ld); -bool videDpt(ListeDepartement ld); -void afficherDpt(ListeDepartement ld); -void afficherDepartement(Departement dpt); -int longueurDpt(ListeDepartement ld); +// Liste Choix +ListeChoix listenouvChoix(void); +ListeChoix insererEnTeteChoix(ListeChoix lc, Choix choix); +ListeChoix insererChoix(ListeChoix lc, Choix choix); +ListeChoix supprimerEnTeteChoix(ListeChoix lc); +ListeChoix supprimerChoix(ListeChoix lc, Choix choix); +bool rechercheChoix(ListeChoix lc, Choix choix); +Choix TeteChoix(ListeChoix lc); +bool videChoix(ListeChoix lc); +void afficherChoix(ListeChoix lc); +int longueurChoix(ListeChoix lc); +void afficherCandidatsChoix(Choix choix); /* Departement lireDpt(FILE *flot); diff --git a/structures.c b/structures.c index b113a78..ea30cc1 100755 --- a/structures.c +++ b/structures.c @@ -1,228 +1,120 @@ #include "SAE.h" -// ListeAdmission +// ListeChoix -ListeAdmission listenouvAdm(void) +ListeChoix listenouvChoix(void) { - ListeAdmission la; - la = NULL; - return la; + ListeChoix lc; + lc = NULL; + return lc; } -ListeAdmission insererEnTeteAdm(ListeAdmission la, int num) +ListeChoix insererEnTeteChoix(ListeChoix lc, Choix choix) { - MaillonAdmission *p; - p = (MaillonAdmission *)malloc(sizeof(MaillonAdmission)); + MaillonChoix *p; + p = (MaillonChoix *)malloc(sizeof(MaillonChoix)); if (p == NULL) { printf("Opérations interdites !!!!\n"); exit(1); } - p->v = candidat; - p->suiv = la; + p->choix = choix; + p->suiv = lc; return p; } -ListeAdmission insererAdm(ListeAdmission la, Admission candidat) +ListeChoix insererChoix(ListeChoix lc, Choix choix) { - if (la == NULL) - return insererEnTeteAdm(la, candidat); - if (candidat.num < la->v.num) - return insererEnTeteAdm(la, candidat); - if (candidat.num > la->v.num) - return la; - la->suiv = insererAdm(la->suiv, candidat); - return la; + if (videChoix(lc)) + return insererEnTeteChoix(lc, choix); + if (strcmp(choix.ville, lc->choix.ville) < 0) + return insererEnTeteChoix(lc, choix); + if (strcmp(choix.ville, lc->choix.ville) == 0) + { + if (strcmp(choix.departement, lc->choix.departement) != 0) + return insererEnTeteChoix(lc, choix); + lc->choix = choix; + } + lc->suiv = insererChoix(lc->suiv, choix); + return lc; } -ListeAdmission supprimerEnTeteAdm(ListeAdmission la) +ListeChoix supprimerEnTeteChoix(ListeChoix lc) { - MaillonAdmission *aux; - if (videAdm(la)) + MaillonChoix *aux; + if (videChoix(lc)) { printf("Opérations interdites !!!!\n"); exit(1); } - aux = la; - la = la->suiv; + aux = lc; + lc = lc->suiv; free(aux); - return la; + return lc; } -ListeAdmission supprimerAdm(ListeAdmission la, Admission candidat) +ListeChoix supprimerChoix(ListeChoix lc, Choix choix) { - if (videAdm(la)) - return la; - if (candidat.num < la->v.num) - return la; - if (candidat.num == la->v.num) - return supprimerEnTeteAdm(la); - la->suiv = supprimerAdm(la->suiv, la->v); - return la; + if (videChoix(lc)) + return lc; + if (strcmp(choix.ville, lc->choix.ville) < 0) + return lc; + if (strcmp(choix.ville, lc->choix.ville) == 0) + if (strcmp(choix.departement, lc->choix.departement) == 0) + return supprimerEnTeteChoix(lc); + lc->suiv = supprimerChoix(lc->suiv, lc->choix); + return lc; } -bool rechercherAdm(ListeAdmission la, Admission candidat) +bool rechercherChoix(ListeChoix lc, Choix choix) { - if (videAdm(la)) + if (videChoix(lc)) return false; - if (candidat.num < la->v.num) + if (strcmp(choix.ville, lc->choix.ville) < 0) return false; - if (candidat.num == la->v.num) - return true; - return rechercherAdm(la->suiv, la->v); + if (strcmp(choix.ville, lc->choix.ville) == 0) + if (strcmp(choix.departement, lc->choix.departement) == 0) + return true; + return rechercherChoix(lc->suiv, lc->choix); } -Admission TeteAdm(ListeAdmission la) +Choix TeteChoix(ListeChoix lc) { - if (videAdm(la)) + if (videChoix(lc)) { printf("Opérations interdites !!!!\n"); exit(1); } - return la->v; /* Retourne un candidat */ + return lc->choix; /* Retourne un choix (ville) */ } -bool videAdm(ListeAdmission la) +bool videChoix(ListeChoix lc) { - return la == NULL; + return lc == NULL; } -void afficherAdm(ListeAdmission la) +void afficherChoix(ListeChoix lc) { - while (!videAdm(la)) + while (!videChoix(lc)) { - afficherCandidatsAdm(TeteAdm(la)); - la = la->suiv; + afficherCandidatsChoix(TeteChoix(lc)); + lc = lc->suiv; } printf("\n"); } -int longueurAdm(ListeAdmission la) +int longueurChoix(ListeChoix lc) { int cpt = 0; - while (!videAdm(la)) + while (!videChoix(lc)) { cpt++; - la = la->suiv; + lc = lc->suiv; } return cpt; } -void afficherCandidatsAdm(Admission candidat) -{ - printf("%d\t%s\t%s\t%d\t%d\t%d\t%d\t%d\t%s\t%s\t%d\t%d", candidat.num, candidat.nom, candidat.prenom, candidat.tabMatiere[0], candidat.tabMatiere[1], candidat.tabMatiere[2], candidat.tabMatiere[3], candidat.nbChoix, candidat.ville); - afficherDpt(candidat.ldept); -} - -// ListeDepartement - -ListeDepartement listenouvDpt(void) -{ - ListeDepartement ld; - ld = NULL; - return ld; -} - -ListeDepartement insererEnTeteDpt(ListeDepartement ld, Departement dpt) +void afficherCandidatsChoix(Choix choix) { - MaillonDepartement *p; - p = (MaillonDepartement *)malloc(sizeof(MaillonDepartement)); - if (p == NULL) - { - printf("Opérations interdites !!!!\n"); - exit(1); - } - p->v = dpt; - p->suiv = ld; - return p; -} - -ListeDepartement insererDpt(ListeDepartement ld, char dpt) -{ - if (ld == NULL) - return insererEnTeteDpt(ld, dpt); - if (strcmp(dpt, ld->v.departement) < 0) - return insererEnTeteDpt(ld, dpt); - if (strcmp(dpt, ld->v.departement) = 0) - return ld; - ld->suiv = insererDpt(ld->suiv, dpt); - return ld; -} - -ListeDepartement supprimerEnTeteDpt(ListeDepartement ld) -{ - MaillonDepartement *aux; - if (videDpt(ld)) - { - printf("Opérations interdites !!!!\n"); - exit(1); - } - aux = ld; - ld = ld->suiv; - free(aux); - return ld; -} - -ListeDepartement supprimerDpt(ListeDepartement ld, char dpt) -{ - if (videDpt(ld)) - return ld; - if (strcmp(dpt, ld->v.departement) < 0) - return ld; - if (strcmp(dpt, ld->v.departement) = 0) - return supprimerEnTeteDpt(ld); - ld->suiv = supprimerDpt(ld->suiv, dpt); - return ld; -} - -bool rechercherDpt(ListeDepartement ld, char dpt) -{ - if (videDpt(ld)) - return false; - if (strcmp(dpt, ld->v.departement) < 0) - return false; - if (strcmp(dpt, ld->v.departement) = 0) - return true; - return rechercherDpt(ld->suiv, dpt); -} - -Departement TeteDpt(ListeDepartement ld) -{ - if (videDpt(ld)) - { - printf("Opérations interdites !!!!\n"); - exit(1); - } - return ld->v; /* Retourne un département */ -} - -bool videDpt(ListeDepartement ld) -{ - return ld == NULL; -} - -void afficherDpt(ListeDepartement ld) -{ - while (!videDpt(ld)) - { - afficherDepartement(TeteDpt(ld)); - ld = ld->suiv; - } - printf("\n"); -} - -void afficherDepartement(Departement dpt) -{ - printf("%s\t%d\t%d\t", dpt.departement, dpt.decisionAdmission, dpt.decisionCandidat); -} - -int longueurDpt(ListeDepartement ld) -{ - int cpt = 0; - while (!videDpt(ld)) - { - cpt++; - ld = ld->suiv; - } - return cpt; + 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