création de la structure candidat (SAE.h) création fonction de base structure candidat (SAE.c) correction de certain élément (SAEl.c)

master
Alexis LAURENT 2 years ago
parent 5ca807fb35
commit 1786af0464

217
SAE.c

@ -599,3 +599,220 @@ void clearpage(void)
scanf("%*c%c", &entre);
system("clear");
}
ListeCandid ListeCandidvide(void)
{
return NULL;
}
ListeCandidDept ListeCandidDeptvide(void)
{
return NULL;
}
ListeCandidDept insererEnTeteCandidDept(ListeCandidDept l, char departement[], char deciDept[], int deciCandid)
{
MaillonCandidDept *m;
m = (MaillonCandidDept *)malloc(sizeof(MaillonCandidDept));
if (m == NULL)
{
printf("Pb maillon");
exit(1);
}
strcpy(m->departement, departement);
m->decisionDept = deciDept;
m->deciCandid = deciCandid;
m->suiv = l;
return m;
}
ListeCandidDept insererCandidDept(ListeCandidDept l, char departement[], int deciDept, int deciCandid)
{
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 l;
l->suiv = insererCandidDept(l->suiv, departement, deciDept, deciCandid);
return l;
}
ListeCandid insererEnTeteCandid(ListeCandid l, char *ville)
{
MaillonCandid *m;
m = (MaillonCandid *)malloc(sizeof(MaillonCandid));
if (m == NULL)
{
printf("Pb maillon");
exit(1);
}
strcpy(ville, l->iutcandid);
m->suiv = l;
return m;
}
ListeCandid insererCandid(ListeCandid l, char *ville)
{
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;
}
ListeCandidDept suppressionEnTeteCandidDept(ListeCandidDept l)
{
MaillonCandidDept *aux;
if(l == NULL)
{
printf("opération interdite !\n");
exit(1);
}
aux = l;
l = l->suiv;
free(aux);
return l;
}
ListeCandidDept suppressionCandidDept(ListeCandidDept l, char *departement)
{
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;
}
ListeCandid suppressionEnTeteCandid(ListeCandid l)
{
MaillonCandid *aux;
if(l == NULL)
{
printf("opération interdite !\n");
exit(1);
}
aux = l;
l = l->suiv;
free(aux);
return l;
}
ListeCandid suppressionCandid(ListeCandid l, char *ville)
{
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);
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)
{
MaillonCandid *aux;
aux = l;
while(aux != NULL)
{
printf("%s\t",aux->iutcandid);
afficherCandidDept(aux->idCandDept);
aux = aux->suiv;
}
printf("\n");
}
int longueur(ListeCandid l)
{
if(l==NULL)
return 0;
return 1 + longueur(l->suiv);
}
Candidat **chargmentCandid(char *nomFich, int tphys, int *tailleL)
{
int i = 0, nbCandidat, nbCandid;
FILE *flot;
Candidat **tcandid;
tcandid = (Candidat *)malloc(sizeof(Candidat) * tphys);
if (tabV == NULL)
{
printf("Erreur malloc tcandid !\n");
exit(1);
}
flot = fopen(nomFich, "r");
if (flot == NULL)
{
printf("Problèmes d'ouverture de fichier !\n");
exit(1);
}
*tailleL = 0;
tcandid[*tailleL] = (Candidat *)malloc(sizeof(Candidat));
if (tcandid[*tailleL] == NULL)
{
printf("Erreur malloc candidat !\n");
fclose(flot);
exit(1);
}
*(tcandid[*tailleL]) = lireCandidat(flot);
while(!feof(flot))
{
}
}
Candidat lireCandidat(FILE *flot)
{
Candidat c;
fscanf(flot,"%a",&c.id);
fscanf(flot,"%s",c.nom);
fgets(c.prenom,30,flot);
c.prenom[strlen(c.prenom) - 1] = '\0';
fscanf(flot,"%d %d %d %d", c.note[0], c.note[1], c.note[2], c.note[3]);
return c;
}
ListeCandid traiterCandidIUT(ListeCandid l, FILE *flot)
{
char ville[30];
fscanf(flot,"%s",ville);
l = insererCandid(l , ville);
return l;
}
ListeCandidDept traiterCandidDept(ListeCandidDept l, FILE *flot)
{
char departement[30];
int deciDept, deciCandid;
fscanf(flot,"%s",departement);
fscanf(flot,"%d",deciDept);
fscanf(flot,"%d",deciCandid);
l = insererCandidDept(l);
return l;
}

22
SAE.h

@ -20,14 +20,25 @@ typedef struct
MaillonDept *idDept;
}VilleIUT;
typedef struct maillonEtu
//#########################################
//#########################################
//#########################################
typedef struct maillonEtuDept
{
char iutCandid[30];
char departement[30];
int decisionDept;
int decisionCandid;
struct maillonEtuDept *suiv;
}MaillonEtuDept, *ListeCandidDept;
typedef struct maillonEtu
{
char iutCandid[30];
MaillonEtuDept *idCandDept;
struct maillonEtu *suiv;
}MaillonCandid, *ListeDeptCandid;
}MaillonCandid, *ListeCandidIUT;
typedef struct
{
@ -35,9 +46,12 @@ typedef struct
char nom[30];
char prenom[30];
int note[4];
MaillonCandid *idCandDept;
MaillonCandid *idCandIUT;
}Candidat;
//#########################################
//#########################################
//#########################################
bool motdepasseVerif(void);

Loading…
Cancel
Save