parent
8095918788
commit
6b4fa3c184
@ -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);
|
||||
}
|
Loading…
Reference in new issue