|
|
|
@ -207,25 +207,6 @@ void global(void)
|
|
|
|
|
tab = chargementVille(nomFich,30,&tailleL);
|
|
|
|
|
printf("\n");
|
|
|
|
|
gestionMenu(tab, tailleL);*/
|
|
|
|
|
int tailleL, i = 0;
|
|
|
|
|
Candidat** tab;
|
|
|
|
|
char nomFich[20];
|
|
|
|
|
strcpy(nomFich,"candidature.txt");
|
|
|
|
|
printf("charg\n");
|
|
|
|
|
tab = chargmentCandid(nomFich, 30, &tailleL);
|
|
|
|
|
printf("\n");
|
|
|
|
|
while(i < 4)
|
|
|
|
|
{
|
|
|
|
|
printf("%d %s %s\t",tab[i]->id, tab[i]->idCandIUT->iutCandid, tab[i]->idCandIUT->idCandDept->departement);
|
|
|
|
|
i = i + 1;
|
|
|
|
|
printf("\n");
|
|
|
|
|
afficherCandid(tab[i]->idCandIUT);
|
|
|
|
|
}
|
|
|
|
|
//tab[0]->idCandIUT = tab[0]->idCandIUT->suiv;
|
|
|
|
|
//printf("%s\n", tab[0]->idCandIUT->iutCandid);
|
|
|
|
|
tab[0]->idCandIUT->idCandDept = tab[0]->idCandIUT->idCandDept->suiv;
|
|
|
|
|
printf("%s\n", tab[0]->idCandIUT->idCandDept->departement);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AffichageVille(VilleIUT **tiut, int nbEle)
|
|
|
|
@ -563,7 +544,7 @@ int plusGrand(VilleIUT **tiut, int nbEle)
|
|
|
|
|
int pge = 0, i;
|
|
|
|
|
for (i = 1; i < nbEle; i++)
|
|
|
|
|
if (strcmp(tiut[i]->ville,tiut[pge]->ville)>0)
|
|
|
|
|
pge = 1;
|
|
|
|
|
pge = i;
|
|
|
|
|
return pge;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -575,42 +556,6 @@ void echanger(VilleIUT **tiut, int i, int j)
|
|
|
|
|
tiut[j] = aux;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int longueurListe(ListeDept l)
|
|
|
|
|
{
|
|
|
|
|
int cpt = 0;
|
|
|
|
|
while (l != NULL)
|
|
|
|
|
{
|
|
|
|
|
cpt += 1;
|
|
|
|
|
l = l->suiv;
|
|
|
|
|
}
|
|
|
|
|
return cpt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SauvegarderIUT(VilleIUT** tabV, int tailleL) {
|
|
|
|
|
int i, nbDept;
|
|
|
|
|
FILE* flot;
|
|
|
|
|
flot = fopen("res.txt","w");
|
|
|
|
|
for (i = 0 ; i < tailleL ; i++) {
|
|
|
|
|
fprintf(flot,"%s\n",tabV[i]->ville);
|
|
|
|
|
nbDept = longueurListe(tabV[i]->idDept);
|
|
|
|
|
fprintf(flot,"%d\n",&nbDept);
|
|
|
|
|
SauvegarderListe(tabV[i]->idDept,flot);
|
|
|
|
|
free(tabV[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SauvegarderListe(ListeDept l, FILE* flot) {
|
|
|
|
|
MaillonDept* tmp;
|
|
|
|
|
while (l->suiv != NULL) {
|
|
|
|
|
tmp = l;
|
|
|
|
|
fprintf(flot,"%s %d %s\n",l->departement,l->nbPers,l->responsable);
|
|
|
|
|
l = l->suiv;
|
|
|
|
|
free(tmp);
|
|
|
|
|
}
|
|
|
|
|
fprintf(flot,"%s %d %s\n",l->departement,l->nbPers,l->responsable);
|
|
|
|
|
free(l);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void clearpage(void)
|
|
|
|
|
{
|
|
|
|
@ -625,93 +570,123 @@ ListeCandid ListeCandidvide(void)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeCandidDept ListeCandidDeptvide(void)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeCandidDept insererEnTeteCandidDept(ListeCandidDept l, char departement[], int deciDept, int deciCandid)
|
|
|
|
|
ListeCandid insererEnTeteCandid(ListeCandid l, char *ville, ChoixDept **tDept)
|
|
|
|
|
{
|
|
|
|
|
MaillonCandidDept *m;
|
|
|
|
|
m = (MaillonCandidDept *)malloc(sizeof(MaillonCandidDept));
|
|
|
|
|
MaillonCandid *m;
|
|
|
|
|
m = (MaillonCandid *)malloc(sizeof(MaillonCandid));
|
|
|
|
|
if (m == NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("Pb maillon");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
strcpy(m->departement, departement);
|
|
|
|
|
m->decisionDept = deciDept;
|
|
|
|
|
m->decisionCandid = deciCandid;
|
|
|
|
|
strcpy(m->iutCandid, ville);
|
|
|
|
|
m->suiv = l;
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeCandidDept insererCandidDept(ListeCandidDept l, char departement[], int deciDept, int deciCandid)
|
|
|
|
|
ListeCandid insererCandid(ListeCandid l, char *ville, ChoixDept **tDept)
|
|
|
|
|
{
|
|
|
|
|
if (l == NULL)
|
|
|
|
|
return insererEnTeteCandidDept(l, departement, deciDept, deciCandid);
|
|
|
|
|
if (strcmp(departement, l->departement) < 0)
|
|
|
|
|
return insererEnTeteCandidDept(l, departement, deciDept, deciCandid);
|
|
|
|
|
if (strcmp(departement, l->departement) == 0)
|
|
|
|
|
return insererEnTeteCandid(l, ville, tDept, tailleP);
|
|
|
|
|
if (strcmp(ville, l->iutCandid) < 0)
|
|
|
|
|
return insererEnTeteCandid(l, ville, tDept, tailleP);
|
|
|
|
|
if (strcmp(ville, l->iutCandid) == 0)
|
|
|
|
|
return l;
|
|
|
|
|
l->suiv = insererCandidDept(l->suiv, departement, deciDept, deciCandid);
|
|
|
|
|
l->suiv = insererCandid(l->suiv, ville, tDept, tailleP);
|
|
|
|
|
return l;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int rechCandiDept(ChoixDept **tDept, int tailleL, char dept[], int *trouve)
|
|
|
|
|
{
|
|
|
|
|
int inf = 0, sup = tailleL + 1, m;
|
|
|
|
|
while(inf <= sup)
|
|
|
|
|
{
|
|
|
|
|
m = (inf + sup)/2;
|
|
|
|
|
if (strcmp(*(tDept[m]).departement, dept)==0)
|
|
|
|
|
{
|
|
|
|
|
*trouve = 1;
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(*(tDept[m]).departement, dept)>0)
|
|
|
|
|
sup = m-1;
|
|
|
|
|
else inf = m+1;
|
|
|
|
|
}
|
|
|
|
|
*trouve = 0;
|
|
|
|
|
return inf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeCandid insererEnTeteCandid(ListeCandid l, char *ville)
|
|
|
|
|
int plusGrandCandidDept(ChoixDept **tDept, int tailleL)
|
|
|
|
|
{
|
|
|
|
|
MaillonCandid *m;
|
|
|
|
|
m = (MaillonCandid *)malloc(sizeof(MaillonCandid));
|
|
|
|
|
if (m == NULL)
|
|
|
|
|
int pge = 0, i;
|
|
|
|
|
for (i = 1; i < tailleL; i++)
|
|
|
|
|
{
|
|
|
|
|
printf("Pb maillon");
|
|
|
|
|
exit(1);
|
|
|
|
|
if(strcmp(*(tDept[i].departement), *(tDept[pge].departement))>0)
|
|
|
|
|
pge = i;
|
|
|
|
|
return pge;
|
|
|
|
|
}
|
|
|
|
|
strcpy(m->iutCandid, ville);
|
|
|
|
|
m->suiv = l;
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeCandid insererCandid(ListeCandid l, char *ville)
|
|
|
|
|
void echangerCandidDept(ChoixDept **tDept, int i, int j)
|
|
|
|
|
{
|
|
|
|
|
if (l == NULL)
|
|
|
|
|
return insererEnTeteCandid(l, ville);
|
|
|
|
|
if (strcmp(ville, l->iutCandid) < 0)
|
|
|
|
|
return insererEnTeteCandid(l, ville);
|
|
|
|
|
if (strcmp(ville, l->iutCandid) == 0)
|
|
|
|
|
return l;
|
|
|
|
|
l->suiv = insererCandid(l->suiv, ville);
|
|
|
|
|
return l;
|
|
|
|
|
ChoixDept *aux;
|
|
|
|
|
aux = tDept[i];
|
|
|
|
|
tDept[i] = tDept[j];
|
|
|
|
|
tDept[j] = aux;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeCandidDept suppressionEnTeteCandidDept(ListeCandidDept l)
|
|
|
|
|
void triEchangeCandidDept(ChoixDept **tDept, int tailleL)
|
|
|
|
|
{
|
|
|
|
|
MaillonCandidDept *aux;
|
|
|
|
|
if(l == NULL)
|
|
|
|
|
int pge;
|
|
|
|
|
while(tailleL > 1)
|
|
|
|
|
{
|
|
|
|
|
printf("opération interdite !\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
pge = plusGrandCandidDept(tDept, tailleL);
|
|
|
|
|
echangerCandidDept(tDept, pge, tailleL - 1)
|
|
|
|
|
tailleL = tailleL - 1
|
|
|
|
|
}
|
|
|
|
|
aux = l;
|
|
|
|
|
l = l->suiv;
|
|
|
|
|
free(aux);
|
|
|
|
|
return l;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeCandidDept suppressionCandidDept(ListeCandidDept l, char *departement)
|
|
|
|
|
ChoixDept ** insererTDept(ChoixDept **tDept, int *tailleP, int *tailleL ,char dept[], int deciDept, int deciCandid)
|
|
|
|
|
{
|
|
|
|
|
if (l == NULL)
|
|
|
|
|
return l;
|
|
|
|
|
if (strcmp(departement, l->departement) < 0)
|
|
|
|
|
return l;
|
|
|
|
|
if (strcmp(departement, l->departement) == 0)
|
|
|
|
|
return suppressionEnTeteCandidDept(l);
|
|
|
|
|
l->suiv = suppressionCandidDept(l->suiv, departement);
|
|
|
|
|
return l;
|
|
|
|
|
ChoixDept **aux;
|
|
|
|
|
aux = tDept;
|
|
|
|
|
int trouve;
|
|
|
|
|
if (*tailleL == *tailleP)
|
|
|
|
|
{
|
|
|
|
|
*tailleP = *tailleP + 10;
|
|
|
|
|
aux = (ChoixDept **)realloc(tDept, *tailleP + 1 * sizeof(ChoixDept *));
|
|
|
|
|
if (aux == NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("pb réalloc\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pos = rechCandiDept(tDept, *tailleL, dept, &trouve);
|
|
|
|
|
if (trouve == 1)
|
|
|
|
|
{
|
|
|
|
|
printf("Departement déjà dans le tableau");
|
|
|
|
|
return aux;
|
|
|
|
|
}
|
|
|
|
|
triEchangeCandidDept(tDept, tailleL)
|
|
|
|
|
strcpy(*(aux[pos]).departement, dept);
|
|
|
|
|
*(aux[pos]).decisionDept = deciDept;
|
|
|
|
|
*(aux[pos]).decisionCandid = deciCandid;
|
|
|
|
|
*tailleL = *tailleL + 1;
|
|
|
|
|
return aux;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeCandid suppressionEnTeteCandid(ListeCandid l)
|
|
|
|
|
void videTabDept(ChoixDept **tDept, int *tailleP)
|
|
|
|
|
{
|
|
|
|
|
ChoixDept *aux;
|
|
|
|
|
int i;
|
|
|
|
|
for (i=tailleP - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
aux = tDept[i];
|
|
|
|
|
free(aux);
|
|
|
|
|
}
|
|
|
|
|
*tailleP = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeCandid suppressionEnTeteCandid(ListeCandid l , ChoixDept **tDept, int *tailleP)
|
|
|
|
|
{
|
|
|
|
|
MaillonCandid *aux;
|
|
|
|
|
if(l == NULL)
|
|
|
|
@ -720,51 +695,34 @@ ListeCandid suppressionEnTeteCandid(ListeCandid l)
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
aux = l;
|
|
|
|
|
videTabDept(tDept, tailleP);
|
|
|
|
|
l = l->suiv;
|
|
|
|
|
free(aux);
|
|
|
|
|
return l;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeCandid suppressionCandid(ListeCandid l, char *ville)
|
|
|
|
|
ListeCandid suppressionCandid(ListeCandid l, char *ville, ChoixDept **tDept, int *tailleP)
|
|
|
|
|
{
|
|
|
|
|
if (l == NULL)
|
|
|
|
|
return l;
|
|
|
|
|
if (strcmp(ville, l->iutCandid) < 0)
|
|
|
|
|
return l;
|
|
|
|
|
if (strcmp(ville, l->iutCandid) == 0)
|
|
|
|
|
{
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
if (l->idCandDept == NULL)
|
|
|
|
|
break;
|
|
|
|
|
suppressionEnTeteCandidDept(l->idCandDept);
|
|
|
|
|
}
|
|
|
|
|
return suppressionEnTeteCandid(l);
|
|
|
|
|
}
|
|
|
|
|
l->suiv = suppressionCandid(l->suiv, ville);
|
|
|
|
|
return suppressionEnTeteCandid(l, tDept, tailleP);
|
|
|
|
|
l->suiv = suppressionCandid(l->suiv, ville, tDept, tailleP);
|
|
|
|
|
return l;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void afficherCandidDept(ListeCandidDept l)
|
|
|
|
|
{
|
|
|
|
|
MaillonCandidDept *aux;
|
|
|
|
|
aux = l;
|
|
|
|
|
while(aux != NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("%s\t%d\t%d\n",aux->departement, aux->decisionDept, aux->decisionCandid);
|
|
|
|
|
aux = aux->suiv;
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void afficherCandid(ListeCandid l)
|
|
|
|
|
void afficherCandid(ListeCandid l,int tailleL)
|
|
|
|
|
{
|
|
|
|
|
MaillonCandid *aux;
|
|
|
|
|
int i;
|
|
|
|
|
aux = l;
|
|
|
|
|
while(aux != NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("%s\t",aux->iutCandid);
|
|
|
|
|
afficherCandidDept(aux->idCandDept);
|
|
|
|
|
for (i = 0; i < tailleL;i++)
|
|
|
|
|
printf("%s %d %d\n", aux->idCandIUT.*(tDept[i]).departement, aux->idCandIUT.*(tDept[i]).decisionDept, aux->idCandIUT.*(tDept[i]).decisionCandid);
|
|
|
|
|
aux = aux->suiv;
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
@ -777,23 +735,26 @@ int longueur(ListeCandid l)
|
|
|
|
|
return 1 + longueur(l->suiv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Candidat **chargmentCandid(char *nomFich, int tphys, int *tailleL)
|
|
|
|
|
Candidat **chargmentCandid(char *nomFich, int *tphys, int *tailleL)
|
|
|
|
|
{
|
|
|
|
|
int i = 0, j = 0, nbCandidat, nbIUT, nbDept;
|
|
|
|
|
int i = 0, j = 0, nbIUT, nbDept;
|
|
|
|
|
FILE *flot;
|
|
|
|
|
Candidat **tcandid;
|
|
|
|
|
tcandid = (Candidat **)malloc(sizeof(Candidat *) * tphys);
|
|
|
|
|
if (tcandid == NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("Erreur malloc tcandid !\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
ChoixDept **tDept;
|
|
|
|
|
flot = fopen(nomFich, "r");
|
|
|
|
|
if (flot == NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("Problèmes d'ouverture de fichier !\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
fscanf(flot,"%d",tphys);
|
|
|
|
|
*tphys = *tphys + 10;
|
|
|
|
|
tcandid = (Candidat **)malloc(sizeof(Candidat *) * *tphys);
|
|
|
|
|
if (tcandid == NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("Erreur malloc tcandid !\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
*tailleL = 0;
|
|
|
|
|
tcandid[*tailleL] = (Candidat *)malloc(sizeof(Candidat));
|
|
|
|
|
if (tcandid[*tailleL] == NULL)
|
|
|
|
@ -802,7 +763,6 @@ Candidat **chargmentCandid(char *nomFich, int tphys, int *tailleL)
|
|
|
|
|
fclose(flot);
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
fscanf(flot,"%d",&nbCandidat);
|
|
|
|
|
*(tcandid[*tailleL]) = lireCandidat(flot);
|
|
|
|
|
while(!feof(flot))
|
|
|
|
|
{
|
|
|
|
@ -811,14 +771,6 @@ Candidat **chargmentCandid(char *nomFich, int tphys, int *tailleL)
|
|
|
|
|
while(i < nbIUT)
|
|
|
|
|
{
|
|
|
|
|
tcandid[*tailleL]->idCandIUT = traiterCandidIUT(tcandid[*tailleL]->idCandIUT, flot);
|
|
|
|
|
fscanf(flot, "%d", &nbDept);
|
|
|
|
|
tcandid[*tailleL]->idCandIUT->idCandDept = ListeCandidDeptvide();
|
|
|
|
|
while(j < nbDept)
|
|
|
|
|
{
|
|
|
|
|
tcandid[*tailleL]->idCandIUT->idCandDept = traiterCandidDept(tcandid[*tailleL]->idCandIUT->idCandDept, flot);
|
|
|
|
|
j = j + 1;
|
|
|
|
|
}
|
|
|
|
|
j = 0;
|
|
|
|
|
i = i + 1;
|
|
|
|
|
}
|
|
|
|
|
i = 0;
|
|
|
|
@ -845,26 +797,32 @@ Candidat lireCandidat(FILE *flot)
|
|
|
|
|
fscanf(flot,"%s%*c",c.nom);
|
|
|
|
|
fgets(c.prenom,30,flot);
|
|
|
|
|
c.prenom[strlen(c.prenom) - 1] = '\0';
|
|
|
|
|
fscanf(flot,"%f %f %f %f", &c.note[0], &c.note[1], &c.note[2], &c.note[3]);
|
|
|
|
|
printf("%d %s %s %f %f %f %f\n",c.id, c.nom, c.prenom,c.note[0], c.note[1], c.note[2], c.note[3] );
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeCandid traiterCandidIUT(ListeCandid l, FILE *flot)
|
|
|
|
|
{
|
|
|
|
|
char ville[30];
|
|
|
|
|
int nbDept, i;
|
|
|
|
|
fscanf(flot,"%s",ville);
|
|
|
|
|
l = insererCandid(l , ville);
|
|
|
|
|
fscanf(flot, "%d", &nbDept);
|
|
|
|
|
tDept = (ChoixDept **)malloc(sizeof(ChoixDept *)*nbDept);
|
|
|
|
|
while (i < nbDept)
|
|
|
|
|
{
|
|
|
|
|
tDept = traiterCandidDept(tDept, i, nbDept, *flot);
|
|
|
|
|
i = i + 1;
|
|
|
|
|
}
|
|
|
|
|
l = insererCandid(l , ville , tDept);
|
|
|
|
|
printf("\n %s \n",l->iutCandid);
|
|
|
|
|
return l;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListeCandidDept traiterCandidDept(ListeCandidDept l, FILE *flot)
|
|
|
|
|
ChoixDept **traiterCandidDept(ChoixDept **tDept,int *tailleL, int *tailleP, FILE *flot)
|
|
|
|
|
{
|
|
|
|
|
char departement[30];
|
|
|
|
|
char dept[30];
|
|
|
|
|
int deciDept, deciCandid;
|
|
|
|
|
fscanf(flot,"%s %d %d",departement, &deciDept, &deciCandid);
|
|
|
|
|
l = insererCandidDept(l, departement, deciDept, deciCandid);
|
|
|
|
|
printf("\n %s %d %d \n", l->departement, l->decisionDept, l->decisionCandid);
|
|
|
|
|
return l;
|
|
|
|
|
fscanf(flot,"%s%*c", dept);
|
|
|
|
|
fscanf(flot,"%d %d", &deciDept, &deciCandid);
|
|
|
|
|
tDept = insererTDept(tDept, tailleP, tailleL , dept, deciDept, deciCandid);
|
|
|
|
|
return tDept;
|
|
|
|
|
}
|