commit
adf63f044e
@ -1,228 +1,120 @@
|
|||||||
#include "SAE.h"
|
#include "SAE.h"
|
||||||
|
|
||||||
// ListeAdmission
|
// ListeChoix
|
||||||
|
|
||||||
ListeAdmission listenouvAdm(void)
|
ListeChoix listenouvChoix(void)
|
||||||
{
|
{
|
||||||
ListeAdmission la;
|
ListeChoix lc;
|
||||||
la = NULL;
|
lc = NULL;
|
||||||
return la;
|
return lc;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListeAdmission insererEnTeteAdm(ListeAdmission la, int num)
|
ListeChoix insererEnTeteChoix(ListeChoix lc, Choix choix)
|
||||||
{
|
{
|
||||||
MaillonAdmission *p;
|
MaillonChoix *p;
|
||||||
p = (MaillonAdmission *)malloc(sizeof(MaillonAdmission));
|
p = (MaillonChoix *)malloc(sizeof(MaillonChoix));
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
printf("Opérations interdites !!!!\n");
|
printf("Opérations interdites !!!!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
p->v = candidat;
|
p->choix = choix;
|
||||||
p->suiv = la;
|
p->suiv = lc;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListeAdmission insererAdm(ListeAdmission la, Admission candidat)
|
ListeChoix insererChoix(ListeChoix lc, Choix choix)
|
||||||
{
|
{
|
||||||
if (la == NULL)
|
if (videChoix(lc))
|
||||||
return insererEnTeteAdm(la, candidat);
|
return insererEnTeteChoix(lc, choix);
|
||||||
if (candidat.num < la->v.num)
|
if (strcmp(choix.ville, lc->choix.ville) < 0)
|
||||||
return insererEnTeteAdm(la, candidat);
|
return insererEnTeteChoix(lc, choix);
|
||||||
if (candidat.num > la->v.num)
|
if (strcmp(choix.ville, lc->choix.ville) == 0)
|
||||||
return la;
|
{
|
||||||
la->suiv = insererAdm(la->suiv, candidat);
|
if (strcmp(choix.departement, lc->choix.departement) != 0)
|
||||||
return la;
|
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;
|
MaillonChoix *aux;
|
||||||
if (videAdm(la))
|
if (videChoix(lc))
|
||||||
{
|
{
|
||||||
printf("Opérations interdites !!!!\n");
|
printf("Opérations interdites !!!!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
aux = la;
|
aux = lc;
|
||||||
la = la->suiv;
|
lc = lc->suiv;
|
||||||
free(aux);
|
free(aux);
|
||||||
return la;
|
return lc;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListeAdmission supprimerAdm(ListeAdmission la, Admission candidat)
|
ListeChoix supprimerChoix(ListeChoix lc, Choix choix)
|
||||||
{
|
{
|
||||||
if (videAdm(la))
|
if (videChoix(lc))
|
||||||
return la;
|
return lc;
|
||||||
if (candidat.num < la->v.num)
|
if (strcmp(choix.ville, lc->choix.ville) < 0)
|
||||||
return la;
|
return lc;
|
||||||
if (candidat.num == la->v.num)
|
if (strcmp(choix.ville, lc->choix.ville) == 0)
|
||||||
return supprimerEnTeteAdm(la);
|
if (strcmp(choix.departement, lc->choix.departement) == 0)
|
||||||
la->suiv = supprimerAdm(la->suiv, la->v);
|
return supprimerEnTeteChoix(lc);
|
||||||
return la;
|
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;
|
return false;
|
||||||
if (candidat.num < la->v.num)
|
if (strcmp(choix.ville, lc->choix.ville) < 0)
|
||||||
return false;
|
return false;
|
||||||
if (candidat.num == la->v.num)
|
if (strcmp(choix.ville, lc->choix.ville) == 0)
|
||||||
return true;
|
if (strcmp(choix.departement, lc->choix.departement) == 0)
|
||||||
return rechercherAdm(la->suiv, la->v);
|
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");
|
printf("Opérations interdites !!!!\n");
|
||||||
exit(1);
|
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));
|
afficherCandidatsChoix(TeteChoix(lc));
|
||||||
la = la->suiv;
|
lc = lc->suiv;
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int longueurAdm(ListeAdmission la)
|
int longueurChoix(ListeChoix lc)
|
||||||
{
|
{
|
||||||
int cpt = 0;
|
int cpt = 0;
|
||||||
while (!videAdm(la))
|
while (!videChoix(lc))
|
||||||
{
|
{
|
||||||
cpt++;
|
cpt++;
|
||||||
la = la->suiv;
|
lc = lc->suiv;
|
||||||
}
|
}
|
||||||
return cpt;
|
return cpt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void afficherCandidatsAdm(Admission candidat)
|
void afficherCandidatsChoix(Choix choix)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
MaillonDepartement *p;
|
printf("Ville : %s\nDépartement : %s\nAdmission : %d\nCandidat : %d\n", choix.ville, choix.departement, choix.decisionAdmission, choix.decisionCandidat);
|
||||||
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;
|
|
||||||
}
|
}
|
Loading…
Reference in new issue