master
DahmaneYanis 2 years ago
commit f4bf6d9e95

@ -0,0 +1,2 @@
Clermont-Ferrand Biologie 120 Perrier Yanic

@ -43,7 +43,7 @@ typedef struct
char prenom[50];
float notes[4];
int nbChoix;
Choix *choix;
lChoix lchoix;
}Candidat;
//Proposition de structure de candidature pour la Partie 3 ( jean ) :
@ -103,7 +103,7 @@ typedef struct
*/
// sae.c
void testJean(void);
void guillaume(void);
void Globale(void);
Log * chargementLog(char * nomFichier, int * nbLog);
@ -122,17 +122,18 @@ void saisieMdp(char * mdp);
void seConnecter(Log * tLog, int nbLog);
void seConnecterTest(void);
int modifiePlacesDept(VilleIut **villeIut, int nbVilles, char *ville, char *nomDept, int nbP);
int modifieRespDept(VilleIut *tVilleIut[], int nbVilles, char ville[], char nomDept[], char nvNomResp[]);
void afficherDeptIutDonne(VilleIut **villeIut, int nbVille);
void afficheIUTDept(VilleIut* *villeIut, int nbVilles, char *nomDept);
void afficheVillesIUT(VilleIut **villeIut, int nbVilles);
void afficheNbPlacesDep(VilleIut *tVilleIut[], int nbVilles, char nomDept[]);
int existeVille( VilleIut * tIut[], char ville[], int nbvilles );
void menuAdmin(VilleIut **villeIut, int nbVilles);
int modifiePlacesDept(VilleIut *tiut[], int nbVilles, char *ville, char *nomDept, int nbP);
int modifieRespDept(VilleIut *tiut[], int nbVilles, char ville[], char nomDept[], char nvNomResp[]);
void afficherDeptIutDonne(VilleIut *tiut[], int nbVilles);
void afficheIUTDept(VilleIut *tiut[], int nbVilles, char *nomDept);
void afficheVillesIUT(VilleIut *tiut[], int nbVilles);
void afficheNbPlacesDep(VilleIut *tiut[], int nbVilles, char nomDept[]);
int existeVille( VilleIut *tiut[], char ville[], int nbvilles );
void menuAdmin(VilleIut *tiut[], int nbVilles);
void afficherCandidat(Candidat candidat);
void afficherCandidats(Candidat *candidats, int nbCandidats);
void afficherUnCandidat(Candidat candidat);
void afficherCandidats(Candidat **candidats, int nbCandidats);
int creerCandidat(Candidat *tCand[], int nbCandidats);
ListeDeptV2 configurationDeptV2( ListeDept ldept );
@ -151,6 +152,11 @@ bool vide(ListeDept ldept);
int longueur(ListeDept ldept);
void afficherListe(ListeDept ldept);
// Choix.c
lChoix ajouterEnteteC( lChoix lchoix, char ville[], char departement[], int decision, int validation);
lChoix supprimerEnTeteC( lChoix lchoix );
lChoix listenouvC();
// iut.c
@ -173,4 +179,9 @@ void tailleSupTabIut(VilleIut ** tIut, int *nbMax);
void fusionIut(VilleIut ** tIut, int * nbIut);
int existe(char * nom, VilleIut ** tIut, int nbIut, int iDepart, int * indice);
void fusion(VilleIut ** tIut, int nbIut, int i, int j);
void supprimerIut(VilleIut ** tIut, int nbIut, int j);
void supprimerIut(VilleIut ** tIut, int nbIut, int j);
// candidat.c
Candidat *modifierCandidat(Candidat *c);

@ -0,0 +1,32 @@
#include "../header/sae.h"
/**
@brief Modifie les informations d'un candidat
@param c Pointeur vers le candidat à modifier
@return Pointeur vers le candidat modifié
*/
Candidat *modifierCandidat(Candidat *c)
{
int choix;
printf("Que voulez vous modifier\n1-Le nom\n2-Le Prenom\n3-Les notes\n");
scanf("%d", &choix);
switch (choix)
{
case 1:
printf("Nom actuel : %s\nVeuillez saisir le nouveau nom\n", c->nom);
fgets(c->nom, 50, stdin);
c->nom[strlen(c->nom) - 1] = '\0';
break;
case 2:
printf("Prenom actuel : %s\nVeuillez saisir le nouveau prenom\n", c->prenom);
fgets(c->nom, 50, stdin);
c->prenom[strlen(c->prenom) - 1] = '\0';
break;
case 3:
printf("Voici les notes actuels : %.2f %.2f %.2f %.2f\nVeuillez saisir les nouvelles notes(note1/note2/note3/note4)", c->notes[0], c->notes[1], c->notes[2], c->notes[3]);
scanf("%f/%f/%f/%f", &c->notes[0], &c->notes[1], &c->notes[2], &c->notes[3]);
break;
}
return c;
}

@ -0,0 +1,67 @@
#include "../header/sae.h"
/**
* @brief Ajoute un choix à la liste de choix
* @param lchoix juste de choix auquel un mayon est rajouté
* @param ville La ville du nouveau choix
* @param departement Le departement du nouveau choix
* @param decision La décision du département pour le choix
* @param validation La validation du candidat pour le choix
* @return La liste avec le nouveau maillon
*/
lChoix ajouterEnteteC( lChoix lchoix, char ville[], char departement[], int decision, int validation)
{
Choix * c = ( Choix * ) malloc ( sizeof ( Choix ));
if ( c == NULL )
{
printf("\n --> Erreur d'allocation memoire \n");
exit(1);
}
strcpy( c -> ville, ville );
strcpy( c -> departement, departement );
c -> decisionDepartement = decision;
c -> validationCandidat = validation;
c -> suiv = lchoix;
lchoix = c;
return lchoix;
}
/**
* @brief supprime un maillon de la liste
* @param lchoix juste de choix auquel un mayon est rajouté
*
* @return La liste avec le maillon en moins
*/
lChoix supprimerEnTeteC( lChoix lchoix )
{
Choix * aux;
if ( lchoix == NULL )
{
printf(" \n --> operation impossible \n");
exit(1);
}
aux = lchoix;
lchoix = lchoix -> suiv;
free( aux );
return lchoix;
}
/**
* @brief Initialise une liste vide
* @return La liste vide
*/
lChoix listenouvC()
{
lChoix l;
l = NULL;
return l;
}

@ -99,7 +99,7 @@ ListeDept ajouterDept(ListeDept ldept, char nomDept[], char resp[], int nbP)
*
* @return La nouvelle liste de départements vide.
*/
ListeDept listenouv()
ListeDept listenouv(void)
{
ListeDept l;

@ -8,8 +8,8 @@ int main(void)
// #ifdef _WIN32
// color
// #endif
testCharge();
//guillaume();
//testCharge();
//Globale();
//testJean();
return 0;

@ -1 +0,0 @@
Clermont-Ferrand Biologie 120 Perrier Yanic

@ -122,7 +122,7 @@ void menuVisiteur(Log * tLog, int nbLog, VilleIut *tIut[], int nbVilles)
printf("Affiche le nombre de place dans un departement (En attente de Guillaume)\n");
break;
case 3 :
printf("Affiche les departements d'un IUT donne (En attente de Loris)\n");
afficherDeptIutDonne(tIut, nbVilles);
break;
case 4 :
printf("Affiche les IUT possedant un departement donne (En attente de Jean)\n");
@ -187,7 +187,7 @@ int choixMenuCandidat(void)
int choix;
choix = afficherMenuCandidat();
while (choix < 0 || choix > 4)
while (choix < 0 || choix > 3)
{
clean
printf("\nChoix incorrect.\n\n");
@ -210,7 +210,6 @@ int afficherMenuCandidat(void)
printf("\t1. Creer une candidature\n");
printf("\t2. Modifier une candidature\n");
printf("\t3. Supprimer une candidature\n");
printf("\t4. Gestion des candidatures\n");
printf("\t0. Quitter\n");
printf("\nChoix : ");
scanf("%d%*c", &choix);
@ -429,16 +428,16 @@ void saisieMdp(char * mdp)
*
* @return 1 si le département a été trouvé et modifié, 0 sinon
*/
int modifiePlacesDept(VilleIut **villeIut, int nbVilles, char *ville, char *nomDept, int nbP)
int modifiePlacesDept(VilleIut *tiut[], int nbVilles, char *ville, char *nomDept, int nbP)
{
// Recherche de la ville et du département
int i;
for (i = 0; i < nbVilles; i++)
{
if (strcmp(villeIut[i] -> nom, ville) == 0)
if (strcmp(tiut[i] -> nom, ville) == 0)
{
// Ville trouvée, recherche du département
MaillonDept *dept = villeIut[i] -> lDept;
MaillonDept *dept = tiut[i] -> lDept;
while ( dept != NULL && strcmp( dept -> nomDept, nomDept) != 0)
{
@ -473,16 +472,16 @@ int modifiePlacesDept(VilleIut **villeIut, int nbVilles, char *ville, char *nomD
*
* @return 1 si le nom du responsable a été trouvé et modifié, 0 sinon
*/
int modifieRespDept(VilleIut *tVilleIut[], int nbVilles, char ville[], char nomDept[], char nvNomResp[])
int modifieRespDept(VilleIut *tiut[], int nbVilles, char ville[], char nomDept[], char nvNomResp[])
{
// Recherche de la ville et du département
int i;
for (i = 0; i < nbVilles; i++)
{
if (strcmp(tVilleIut[i] -> nom, ville) == 0)
if (strcmp(tiut[i] -> nom, ville) == 0)
{
// Ville trouvée, recherche du département
MaillonDept *dept = tVilleIut[i] -> lDept;
MaillonDept *dept = tiut[i] -> lDept;
while ( dept != NULL && strcmp( dept -> nomDept, nomDept) != 0)
{
@ -506,31 +505,37 @@ int modifieRespDept(VilleIut *tVilleIut[], int nbVilles, char ville[], char nomD
return 0;
}
/*void afficherDeptIutDonne(VilleIut **villeIut, int nbVille)
/**
*@brief Affiche les départements d'un IUT donné
*@param tiut tableau des villes d'IUT
*@param nbVille nombre de villes d'IUT dans le tableau
*@return void
*/
void afficherDeptIutDonne(VilleIut *tiut[], int nbVille)
{
int res;
char *nom;
afficheVillesIUT(villeIut, nbVille);
afficheVillesIUT(tiut, nbVille);
printf("Veuillez saisir le nom de l'iut que vous voulez afficher.\n");
scanf("%s", nom);
res = existeVille(villeiut, nbVille, nom);
res = existeVille(tiut, nom, nbVille);
if (res == -1)
{
printf("Cet IUT n'existe pas\n");
return ;
}
afficherListe(villeiut[res]->lDept);
}*/
afficherListe(tiut[res]->lDept);
}
/**
* @brief Affiche les IUT possédant un département spécifique.
*
* @param villeIut tableau de pointeurs sur les structures VilleIut
* @param tiut tableau de pointeurs sur les structures VilleIut
* @param nbVilles nombre de villes dans le tableau villeIut
* @param nomDept nom du département à rechercher
*/
void afficheIUTDept(VilleIut **villeIut, int nbVilles, char *nomDept)
void afficheIUTDept(VilleIut *tiut[], int nbVilles, char *nomDept)
{
clean;
printf("==========================================================================\n");
@ -542,13 +547,13 @@ void afficheIUTDept(VilleIut **villeIut, int nbVilles, char *nomDept)
for (i = 0; i < nbVilles; i++)
{
// Parcours de la liste chaînée de départements de la ville
MaillonDept *dept = villeIut[i] -> lDept;
MaillonDept *dept = tiut[i] -> lDept;
while (dept != NULL)
{
if (strcmp(dept->nomDept, nomDept) == 0)
{
// Département trouvé, affichage de la ville
printf(" -> IUT de %s\n", villeIut[i] -> nom);
printf(" -> IUT de %s\n", tiut[i] -> nom);
e = 1;
}
@ -565,7 +570,7 @@ void afficheIUTDept(VilleIut **villeIut, int nbVilles, char *nomDept)
* @param villeIut tableau de pointeurs sur les structures VilleIut
* @param nbVilles nombre de villes dans le tableau villeIut
*/
void afficheVillesIUT(VilleIut **villeIut, int nbVilles)
void afficheVillesIUT(VilleIut *tiut[], int nbVilles)
{
clean
printf("==============================================================\n");
@ -575,7 +580,7 @@ void afficheVillesIUT(VilleIut **villeIut, int nbVilles)
for (int i = 0; i < nbVilles; i++)
{
// Affichage du nom de la ville
printf(" -> %s\n", villeIut[i]-> nom);
printf(" -> %s\n", tiut[i]-> nom);
}
printf(" \n\n\n");
}
@ -587,19 +592,19 @@ void afficheVillesIUT(VilleIut **villeIut, int nbVilles)
* @param nbVilles nombre de villes dans le tableau villeIut
* @param nomDept nom du département à rechercher
*/
void afficheNbPlacesDep(VilleIut *tVilleIut[], int nbVilles, char nomDept[])
void afficheNbPlacesDep(VilleIut *tiut[], int nbVilles, char nomDept[])
{
int i;
for (i = 0; i < nbVilles; i++)
{
// Parcours de la liste chaînée de départements de la ville
MaillonDept *dept = tVilleIut[i] -> lDept;
MaillonDept *dept = tiut[i] -> lDept;
while (dept != NULL)
{
if (strcmp(dept->nomDept, nomDept) == 0)
{
// Département trouvé, affichage de la ville et de son nombre de places
printf("IUT de %s avec %d places.\n", tVilleIut[i] -> nom, tVilleIut[i] -> lDept -> nbP);
printf("IUT de %s avec %d places.\n", tiut[i] -> nom, tiut[i] -> lDept -> nbP);
break;
}
dept = dept->suiv;
@ -607,17 +612,18 @@ void afficheNbPlacesDep(VilleIut *tVilleIut[], int nbVilles, char nomDept[])
}
}
/*int existeVille( VilleIut * tIut[], char ville[], int nbvilles )
int existeVille(VilleIut *tIut[], char ville[], int nbvilles )
{
int i = 0;
//recherche de la ville
for( e = 0; i < nbvilles; i ++ )
for( i = 0; i < nbvilles; i ++ )
{
if ( strcmp( tIut[i] -> nom, ville ) == 0 ) return i; // ville trouvée...
}
return -1;
}*/
}
/**
* Affiche et gère le menu administrateur.
@ -685,9 +691,6 @@ void menuAdmin(VilleIut **villeIut, int nbVilles)
/*
================================================
Partie 2
@ -698,22 +701,27 @@ void menuAdmin(VilleIut **villeIut, int nbVilles)
* @brief Affiche les informations d'un candidat
* @param candidat Le candidat à afficher
*/
void afficherCandidat(Candidat candidat)
{
printf("Numéro du candidat : %d\n", candidat.numero);
printf("Nom : %s\n", candidat.nom);
printf("Prénom : %s\n", candidat.prenom);
printf("Notes : %.2f %.2f %.2f %.2f\n", candidat.notes[0], candidat.notes[1], candidat.notes[2], candidat.notes[3]);
printf("Nombre de choix : %d\n", candidat.nbChoix);
for (int i = 0; i < candidat.nbChoix; i++)
{
printf("Choix %d :\n", i + 1);
printf(" Ville : %s\n", candidat.choix[i].ville);
printf(" Département : %s\n", candidat.choix[i].departement);
printf(" Décision du département : %d\n", candidat.choix[i].decisionDepartement);
printf(" Validation : %d\n", candidat.choix[i].validationCandidat);
void afficherUnCandidat(Candidat candidat)
{
int c = 1;
printf("Candidat numero %7d ", candidat.numero);
printf(" | Nom : %10s | ", candidat.nom);
printf(" Prenom : %10s | ", candidat.prenom);
printf(" | Notes : %2f %2f %2f %2f | ", candidat.notes[0], candidat.notes[1], candidat.notes[2], candidat.notes[3]);
printf(" Nombre de choix : %d\n\n", candidat.nbChoix);
printf(" \n Choix du candidat :\n");
printf( " -------------------\n\n");
while ( candidat.lchoix != NULL )
{
printf(" %d.) Iut : %10s ; departement : %10s ; decision Departement : %d ; validation candidat : %d\n",
candidat.lchoix -> ville, candidat.lchoix -> departement, candidat.lchoix -> decisionDepartement,
candidat.lchoix -> validationCandidat);
}
}
printf(" \n\n");
}
/**
* @brief Affiche la liste des candidats
@ -721,15 +729,100 @@ void afficherCandidat(Candidat candidat)
* @param candidats Le tableau de candidats à afficher
* @param nbCandidats Le nombre de candidats dans le tableau
*/
void afficherCandidats(Candidat *candidats, int nbCandidats)
void afficherCandidats(Candidat **candidats, int nbCandidats)
{
for (int i = 0; i < nbCandidats; i++)
{
printf("\nCandidat %d :\n", i + 1);
afficherCandidat(candidats[i]);
printf("\nCandidat numero %8d | Nom : %10s | Prenom : %10s \n", candidats[i] -> numero,
candidats[i] -> nom, candidats[i] -> prenom);
}
}
/**
* @brief Permet de créer un candidat
*
* @param tCand Tableau de pointeur sur une structure de candidat
* @param nbCandidats nombre de candidats créés
*
* @return Retourne le nombre de candidats
*/
int creerCandidat(Candidat *tCand[], int nbCandidats)
{
int i=0;
Candidat *c;
c = (Candidat *) malloc (sizeof(Candidat));
if(c==NULL)
{
printf("Probleme malloc\n");
exit(1);
}
c->numero = nbCandidats+1;
printf("Le numero du candidat entrain d'etre cree est : %d\n", c->numero);
printf("Nom du candidat (peut contenir des espaces): ");
fgets(c->nom, 50, stdin);
c->nom[strlen(c->nom) - 1] = '\0';
printf("Prenom du candidat (peut contenir des espaces): ");
fgets(c->prenom, 50, stdin);
c->prenom[strlen(c->prenom) - 1] = '\0';
i=0;
while(i<4)
{
printf("Rentrez la note numero %d : ", i+1);
scanf("%f", &c->notes[i]);
while(c->notes[i] < 0 || c->notes[i] > 20)
{
printf("Erreur, la note doit etre comprise entre 0 et 20.\nRessaisir la note numero %d : ", i+1);
scanf("%f", &c->notes[i]);
}
i = i + 1;
}
c->lchoix = listenouvC();
tCand[nbCandidats] = c;
return nbCandidats + 1;
}
/**
* @brief Supprime un choix de la liste de choix d'un candidat
*
* @param lchoix la liste de choix à modifier
* @param nbchoix le nombre de choix dans la liste de choix
*
* @return la liste avec le choix en moins
*/
lChoix supprimerCandidature( lChoix l, int * nbchoix)
{
if ( l == NULL )
{
printf(" \n --> Le candidat ne possede aucun choix...\n\n");
return l;
}
printf("\n Voici les choix du candidat : \n");
printf( " -----------------------------\n\n");
int rep = 0, c = 0;
for( int i = 0; i < *nbchoix; i ++ )
{
printf(" %d.) Ville : %10s ; Departement : %10s \n",i + 1, l -> ville, l -> departement);
}
printf(" \n\n --> Quel choix supprimer ? : ");
scanf("%d%*c", &rep);
while ( c != rep - 1 )
{
l = l -> suiv;
c = c + 1;
}
l = supprimerEnTeteC( l );
*nbchoix = *nbchoix - 1;
return l;
}
/*
================================================
Partie 3

@ -35,3 +35,20 @@
// }
// }
// }
void guillaume(void)
{
Candidat *tCandid[50];
int nbCandidats=0;
nbCandidats = creerCandidat(tCandid, nbCandidats);
printf("\n%d\n", nbCandidats);
afficherCandidats(tCandid, nbCandidats);
}

Loading…
Cancel
Save