From 180d2991db4d352e67187c2ea39ffe0ad0ceec48 Mon Sep 17 00:00:00 2001 From: loris OBRY Date: Fri, 13 Jan 2023 17:09:11 +0100 Subject: [PATCH] Changement organisation des fonctions --- header/sae.h | 8 ++-- source/sae.c | 104 --------------------------------------------------- 2 files changed, 4 insertions(+), 108 deletions(-) diff --git a/header/sae.h b/header/sae.h index b5cfcad..3e506df 100644 --- a/header/sae.h +++ b/header/sae.h @@ -137,10 +137,6 @@ int creerCandidat(Candidat *tCand[], int nbCandidats); ListeDeptV2 configurationDeptV2( ListeDept ldept ); -void affichageListesDept( ListeCandidats lcand, char * type, char * nomDept ); -ListeCandidats trierListeCandidats( ListeCandidats l ); -ListeCandidats insertionCroissanteCand( ListeCandidats nvL, ListeCandidats l ); -ListeCandidats insertionTeteCand( ListeCandidats nvL, ListeCandidats l ); // listeDeparements.c ListeDept ajouterEnTete(ListeDept ldept, char nomDept[], char resp[], int nbP); @@ -181,3 +177,7 @@ void tailleSupTabIut(VilleIut ** tIut, int *nbMax); // candidat.c Candidat *modifierCandidat(Candidat *c); +void affichageListesDept( ListeCandidats lcand, char * type, char * nomDept ); +ListeCandidats trierListeCandidats( ListeCandidats l ); +ListeCandidats insertionCroissanteCand( ListeCandidats nvL, ListeCandidats l ); +ListeCandidats insertionTeteCand( ListeCandidats nvL, ListeCandidats l ); diff --git a/source/sae.c b/source/sae.c index 9dd1488..b4cf500 100644 --- a/source/sae.c +++ b/source/sae.c @@ -882,108 +882,4 @@ ListeDeptV2 configurationDeptV2( ListeDept ldept ) } return lDeptV2; -} - -/* -================================================ - Partie 4 -================================================ -*/ - -/** - * @brief Affiche une liste de candidats après l'avoir triée par ordre alphabétique - * - * @param lcand liste de candidats à trier et afficher - * @param type type de liste à afficher ( en attente ou admis ) - * @param nomDept nom du departement dont est issu la liste - */ -void affichageListesDept( ListeCandidats lcand, char * type, char * nomDept ) -{ - lcand = trierListeCandidats( lcand ); - - printf( " Liste des candidats %s du departement %10s \n -------------------------------------------------------\n\n", type, nomDept); - - while ( lcand != NULL) - { - printf(" | Nom : %10s | Prenom : %10s | Numero : %8s |\n", - lcand -> candidat.nom, lcand -> candidat.prenom, lcand -> candidat.numero); - - lcand = lcand -> suiv; - } -} -/** - * @brief Trie par ordre alphabétique les candidats d'une liste - * - * @param l liste de candidats à trier. - * - * @return La liste triée - */ -ListeCandidats trierListeCandidats( ListeCandidats l ) -{ - ListeCandidats nvL; - - while ( l != NULL ) - { - nvL = insertionCroissanteCand( nvL, l ); - l = l -> suiv; - } - - return nvL; -} - -/** - * @brief Permet d'insérer un nouveau Maillon de candidats dans la liste par ordre alphabétique - * @param l la liste dont est issu le maillon à insérer - * @param nvL la nouvelle liste où est inséré le maillon - * - * @return La nouvelle liste avec le maillon au bon endroit - */ -ListeCandidats insertionCroissanteCand( ListeCandidats nvL, ListeCandidats l ) -{ - if ( l == NULL) - { - nvL = insertionTeteCand( nvL, l ); - return nvL; - } - - if ( strcmp( l -> candidat.nom, nvL -> candidat.nom ) < 0 ) - { - nvL = insertionTeteCand( nvL, l ); - return nvL; - } - - if ( strcmp( l -> candidat.nom, nvL -> candidat.nom ) == 0 ) - { - if ( strcmp( l -> candidat.prenom, nvL -> candidat.prenom ) < 0 ) - { - nvL = insertionTeteCand( nvL, l ); - return nvL; - } - } - - nvL -> suiv = insertionCroissanteCand( nvL -> suiv, l ); - return nvL; -} - -/** - * @brief Insère en tête de la nouvelle liste un nouveau maillon - * @param l liste d'où est issu le nouveau maillon à intégrer - * @param nvL Liste où est insérer le nouveau Maillon - * @return La nouvelle liste avec le maillon au bon endroit - */ -ListeCandidats insertionTeteCand( ListeCandidats nvL, ListeCandidats l ) -{ - MaillonCandidat * m = ( MaillonCandidat * ) malloc ( sizeof( MaillonCandidat )); - if ( m == NULL ) - { - printf("\n -> Erreur allocation memoire...\n"); - exit(1); - } - - m -> candidat = l -> candidat; - m -> suiv = nvL; - nvL = m; - free( l ); - - return nvL; } \ No newline at end of file