@ -87,16 +87,16 @@ int choixMenu(void)
int choixMenuAffichage ( void )
int choixMenuAffichage ( void )
{
{
int choix ;
char choix ;
printf ( " \t Gestion des matières \n " ) ;
printf ( " \t Gestion des matières \n " ) ;
printf ( " 1 .\t Affichage des informations d'un adhérent \n " ) ;
printf ( " A .\t Affichage des informations d'un adhérent \n " ) ;
printf ( " 2 .\t Affichage des informations de tous les adhérents \n " ) ;
printf ( " B .\t Affichage des informations de tous les adhérents \n " ) ;
printf ( " 3 .\t Affichage du nombre d’ entrées totale de toutes les journée \n " ) ;
printf ( " C .\t Affichage du nombre d’ entrées totale de toutes les journée \n " ) ;
printf ( " 4 .\t Affichage du nombre d'entrées totale depuis le début \n " ) ;
printf ( " D .\t Affichage du nombre d'entrées totale depuis le début \n " ) ;
printf ( " 5 .\t Affichage du nombre total d'adhérents \n " ) ;
printf ( " E .\t Affichage du nombre total d'adhérents \n " ) ;
printf ( " 6 .\t quitter \n " ) ;
printf ( " F .\t quitter \n " ) ;
printf ( " \n option choisie : \n " ) ;
printf ( " \n option choisie : \n " ) ;
scanf ( " % d " , & choix ) ;
scanf ( " % *c%c " , & choix ) ;
return choix ;
return choix ;
}
}
@ -113,17 +113,57 @@ int rechercheAdherent(int tNoCarte[], int nbelem, int NoCarte, int *trouve)
if ( tNoCarte [ i ] > NoCarte )
if ( tNoCarte [ i ] > NoCarte )
{
{
* trouve = 0 ;
* trouve = 0 ;
return i ;
return i + 1 ;
}
}
}
}
}
}
int AjoutAdherent ( int tNoCarte [ ] , int tage [ ] , int tPointsCarte [ ] , int tCarteActive [ ] , int tmax , int nbelem )
{
int NoCarte , age , pointsCarte , CarteActive , pas , trouve , j ;
char reponse ;
printf ( " Donnez l'âge de l'adhérent : \n " ) ;
scanf ( " %d " , & age ) ;
pas = rechercheAdherent ( tNoCarte , nbelem , NoCarte , & trouve ) ;
printf ( " %d \n " , pas ) ;
for ( j = nbelem ; j > pas ; j - - )
{
if ( j = = tmax )
{
printf ( " Tableau plein, impossible d'ajouter un adhérent \n " ) ;
return - 1 ;
}
tNoCarte [ j ] = tNoCarte [ j - 1 ] ;
tage [ j ] = tage [ j - 1 ] ;
tPointsCarte [ j ] = tPointsCarte [ j - 1 ] ;
tCarteActive [ j ] = tCarteActive [ j - 1 ] ;
}
tNoCarte [ pas ] = pas + 1 ;
printf ( " %d \n " , tNoCarte [ pas ] ) ;
tage [ pas ] = age ;
tPointsCarte [ pas ] = 0 ;
tCarteActive [ pas ] = 0 ;
nbelem + + ;
printf ( " Le numero de carte de l'adherent qui a %d ans est %d. \n La carte n'est pas active car il n'y a pas de points dessus. \n Voulez-vous en ajouter ? (O / N) " , tage [ pas ] , tNoCarte [ pas ] ) ;
scanf ( " %*c%c " , & reponse ) ;
if ( reponse = = ' O ' | | reponse = = ' o ' )
{
AjoutPoints ( tNoCarte , tPointsCarte , tCarteActive , nbelem ) ;
}
else
{
printf ( " La carte n'est pas active. \n " ) ;
return nbelem ;
}
return nbelem ;
}
void Affichage1Adherent ( int tNoCarte [ ] , int tage [ ] , int tPointsCarte [ ] , int tCarteActive [ ] , int nbelem )
void Affichage1Adherent ( int tNoCarte [ ] , int tage [ ] , int tPointsCarte [ ] , int tCarteActive [ ] , int nbelem )
{
{
int pas , NoCarte , CarteActive , trouve ;
int pas , NoCarte , CarteActive , trouve ;
printf ( " Entrez le numéro de la carte de l'adhérent recherché : " ) ;
printf ( " Entrez le numéro de la carte de l'adhérent recherché : " ) ;
scanf ( " %d " , & NoCarte ) ;
scanf ( " %d " , & NoCarte ) ;
pas = rechercheAdherant ( tNoCarte , nbelem , NoCarte , & trouve ) ;
pas = rechercheAdher e nt( tNoCarte , nbelem , NoCarte , & trouve ) ;
if ( trouve = = 1 )
if ( trouve = = 1 )
{
{
printf ( " N°_de_carte \t Age Points Carte_active \n " ) ;
printf ( " N°_de_carte \t Age Points Carte_active \n " ) ;
@ -181,6 +221,7 @@ void gestionMenus(void)
int tNoCarte [ 20 ] = { 0 } , tage [ 20 ] = { 0 } , tPointsCarte [ 20 ] = { 0 } , tCarteActive [ 20 ] = { 0 } ;
int tNoCarte [ 20 ] = { 0 } , tage [ 20 ] = { 0 } , tPointsCarte [ 20 ] = { 0 } , tCarteActive [ 20 ] = { 0 } ;
int tDate [ 20 ] = { 0 } , tNbActivitesJour [ 20 ] = { 0 } ;
int tDate [ 20 ] = { 0 } , tNbActivitesJour [ 20 ] = { 0 } ;
int tmax = 20 , nbelem , choix , pasAct ;
int tmax = 20 , nbelem , choix , pasAct ;
char choixA ;
nbelem = Ouverture ( tNoCarte , tage , tPointsCarte , tCarteActive , tNbActivitesJour , tDate , tmax , & pasAct ) ;
nbelem = Ouverture ( tNoCarte , tage , tPointsCarte , tCarteActive , tNbActivitesJour , tDate , tmax , & pasAct ) ;
if ( nbelem < 0 )
if ( nbelem < 0 )
{
{
@ -192,30 +233,30 @@ void gestionMenus(void)
{
{
if ( choix = = 1 )
if ( choix = = 1 )
{
{
choix = choixMenuAffichage ( ) ;
choix A = choixMenuAffichage ( ) ;
while ( choix ! = 6 )
while ( choix A ! = ' F ' & & choixA ! = ' f ' )
{
{
if ( choix = = 1 )
if ( choix A = = ' A ' | | choixA = = ' a ' )
{
{
Affichage1Adherent ( tNoCarte , tage , tPointsCarte , tCarteActive , nbelem ) ;
Affichage1Adherent ( tNoCarte , tage , tPointsCarte , tCarteActive , nbelem ) ;
}
}
if ( choix = = 2 )
if ( choix A = = ' B ' | | choixA = = ' b ' )
{
{
AffichageTousAdherents ( tNoCarte , tage , tPointsCarte , tCarteActive , nbelem ) ;
AffichageTousAdherents ( tNoCarte , tage , tPointsCarte , tCarteActive , nbelem ) ;
}
}
if ( choix = = 3 )
if ( choix A = = ' C ' | | choixA = = ' c ' )
{
{
AffichageNbEntreesTousJour ( tNbActivitesJour , tDate , nbelem ) ;
AffichageNbEntreesTousJour ( tNbActivitesJour , tDate , nbelem ) ;
}
}
if ( choix = = 4 )
if ( choix A = = ' D ' | | choixA = = ' d ' )
{
{
AffichageNbEntreesTotal ( tNbActivitesJour , nbelem ) ;
AffichageNbEntreesTotal ( tNbActivitesJour , nbelem ) ;
}
}
if ( choix = = 5 )
if ( choix A = = ' E ' | | choixA = = ' e ' )
{
{
AffichageNbAdherents ( nbelem ) ;
AffichageNbAdherents ( nbelem ) ;
}
}
choix = choixMenuAffichage ( ) ;
choix A = choixMenuAffichage ( ) ;
}
}
}
}
if ( choix = = 2 )
if ( choix = = 2 )
@ -233,7 +274,7 @@ void gestionMenus(void)
if ( choix = = 5 )
if ( choix = = 5 )
{
{
AjoutPoints ( tNoCarte , tPointsCarte , nbelem) ;
AjoutPoints ( tNoCarte , tPointsCarte , tCarteActive, nbelem) ;
}
}
if ( choix = = 6 )
if ( choix = = 6 )
{
{
@ -241,7 +282,7 @@ void gestionMenus(void)
}
}
if ( choix = = 7 )
if ( choix = = 7 )
{
{
DebitActivitee ( tNoCarte , t Points Carte, tNbActivitesJour , tDate, nbelem, & pasAct ) ;
DebitActivitee ( tNoCarte , t CarteActiv e, tNbActivitesJour , nbelem) ;
}
}
choix = choixMenu ( ) ;
choix = choixMenu ( ) ;
}
}
@ -251,10 +292,10 @@ void gestionMenus(void)
void ModificationAge ( int tNoCarte [ ] , int tage [ ] , int nbelem )
void ModificationAge ( int tNoCarte [ ] , int tage [ ] , int nbelem )
{
{
int pas , NoCarte , age ;
int pas , NoCarte , age , trouve ;
printf ( " Entrez le numéro de la carte de l'adhérent recherché : " ) ;
printf ( " Entrez le numéro de la carte de l'adhérent recherché : " ) ;
scanf ( " %d " , & NoCarte ) ;
scanf ( " %d " , & NoCarte ) ;
pas = rechercheAdher a nt( tNoCarte , nbelem , NoCarte , & trouve ) ;
pas = rechercheAdher e nt( tNoCarte , nbelem , NoCarte , & trouve ) ;
if ( trouve = = 1 )
if ( trouve = = 1 )
{
{
printf ( " Entrez l'age de l'adhérent : " ) ;
printf ( " Entrez l'age de l'adhérent : " ) ;
@ -268,12 +309,40 @@ void ModificationAge(int tNoCarte[], int tage[], int nbelem)
}
}
}
}
int Sauvegarde ( int tNoCarte [ ] , int tage [ ] , int tPointsCarte [ ] , int tCarteActive [ ] , int tNbActivitesJour [ ] , int tDate [ ] , int nbelem )
{
int i , j ;
FILE * flot , * jour ;
flot = fopen ( " membres.don " , " a " ) ;
jour = fopen ( " ActivitesJour.don " , " a " ) ;
if ( flot = = NULL )
{
printf ( " Pb d'ouverture du fichier membres.don \n " ) ;
return - 1 ;
}
if ( jour = = NULL )
{
printf ( " Pb d'ouverture du fichier ActivitesJour.don \n " ) ;
return - 1 ;
}
for ( i = 0 ; i < ( nbelem - 1 ) ; i + + )
{
fprintf ( flot , " \t %d \t %d \t \t %d \t \t %d \n " , tNoCarte [ i ] , tage [ i ] , tPointsCarte [ i ] , tCarteActive [ i ] ) ;
}
for ( j = 0 ; j < ( nbelem - 1 ) ; j + + )
{
fprintf ( jour , " %d \t \t %d \n " , tDate [ j ] , tNbActivitesJour [ j ] ) ;
}
fclose ( jour ) ;
fclose ( flot ) ;
}
int SupprimmerAdherent ( int tNoCarte [ ] , int tage [ ] , int tPointsCarte [ ] , int tCarteActive [ ] , int nbelem )
int SupprimmerAdherent ( int tNoCarte [ ] , int tage [ ] , int tPointsCarte [ ] , int tCarteActive [ ] , int nbelem )
{
{
int pas , i , NoCarte , trouve ;
int pas , i , NoCarte , trouve ;
printf ( " Entrez le numéro de la carte de l'adhérent recherché : " ) ;
printf ( " Entrez le numéro de la carte de l'adhérent recherché : " ) ;
scanf ( " %d " , & NoCarte ) ;
scanf ( " %d " , & NoCarte ) ;
pas = rechercheAdherant ( tNoCarte , nbelem , NoCarte , & trouve ) ;
pas = rechercheAdher e nt( tNoCarte , nbelem , NoCarte , & trouve ) ;
if ( trouve = = 1 )
if ( trouve = = 1 )
{
{
for ( i = pas ; i < nbelem ; i + + )
for ( i = pas ; i < nbelem ; i + + )
@ -294,89 +363,54 @@ int SupprimmerAdherent(int tNoCarte[], int tage[], int tPointsCarte[], int tCart
}
}
int AjoutAdherent ( int tNoCarte [ ] , int t age[ ] , int t PointsCarte[ ] , int tCarteActive [ ] , int tmax , int nbelem )
void AjoutPoints ( int tNoCarte [ ] , int t PointsCarte[ ] , int tCarteActive [ ] , int nbelem )
{
{
int NoCarte , age , pointsCarte , CarteActive , pas ;
int pointsCarte , NoCarte , trouve , pas ;
char reponse ;
printf ( " Donnez l'âge de l'adhérent : \n " ) ;
scanf ( " %d " , & age ) ;
pas = rechercheAdherant ( tNoCarte , nbelem ) ;
for ( j = nbelem ; j > pas ; j - - )
{
if ( j = = tmax )
{
printf ( " Tableau plein, impossible d'ajouter un adhérent \n " ) ;
return - 1 ;
}
tNoCarte [ j ] = tNoCarte [ j - 1 ] ;
tage [ j ] = tage [ j - 1 ] ;
tPointsCarte [ j ] = tPointsCarte [ j - 1 ] ;
tCarteActive [ j ] = tCarteActive [ j - 1 ] ;
}
tNoCarte [ pas ] = pas + 1 ;
tage [ pas ] = age ;
tPointsCarte [ pas ] = 0 ;
tCarteActive [ pas ] = 0 ;
nbelem + + ;
printf ( " Le numero de carte de l'adherent qui a %d ans est %d. \n La carte n'est pas active car il n'y a pas de points dessus. \n Voulez-vous en ajouter ? (O / N) " , tage [ pas ] , tNoCarte [ pas ] ) ;
scanf ( " %*c%c " , & reponse ) ;
if ( reponse = = ' O ' | | reponse = = ' o ' )
{
AjoutPoints ( tNoCarte , tPointsCarte , tCarteActive , nbelem , pas ) ;
}
else
{
printf ( " La carte n'est pas active. \n " ) ;
return nbelem ;
}
return nbelem ;
}
void AjoutPoints ( int tNoCarte [ ] , int tPointsCarte [ ] , int tCarteActive [ ] , int nbelem , int pas )
{
int pointsCarte , NoCarte , trouve ;
printf ( " Entrez le numéro de la carte de l'adhérent recherché : " ) ;
printf ( " Entrez le numéro de la carte de l'adhérent recherché : " ) ;
scanf ( " %d " , & NoCarte ) ;
scanf ( " %d " , & NoCarte ) ;
pas = rechercheAdher a nt( tNoCarte , nbelem , NoCarte , & trouve ) ;
pas = rechercheAdherent ( tNoCarte , nbelem , NoCarte , & trouve ) ;
if ( trouve = = 1 )
if ( trouve = = 1 )
{
{
printf ( " Entrez le nombre de points a ajouter: " ) ;
printf ( " Entrez le nombre de points a ajouter: " ) ;
scanf ( " %d " , & pointsCarte ) ;
scanf ( " %d " , & pointsCarte ) ;
if ( pointsCarte > 0 & & pointsCarte < 20 )
if ( pointsCarte > 0 & & pointsCarte < = 20 )
{
{
tPointsCarte [ pas ] = pointsCarte ;
tPointsCarte [ pas ] = pointsCarte ;
tCarteActive [ pas ] = 1 ;
tCarteActive [ pas ] = 1 ;
printf ( " La carte est active. \n " ) ;
printf ( " La carte est active. \n " ) ;
}
}
if ( pointsCarte > 20 & & pointsCarte < 50 )
else
{
if ( pointsCarte > 20 & & pointsCarte < = 50 )
tPointsCarte [ pas ] = pointsCarte + pointsCarte * ( 1 + ( 5 / 100.0 ) ) ;
{
tCarteActive [ pas ] = 1 ;
tPointsCarte [ pas ] = pointsCarte + pointsCarte * ( 1 + ( 5 / 100.0 ) ) ;
printf ( " Merci pour votre achat. Nous vous offrons 5%% supplémentaires. De plus, votre carte est active. \n " ) ;
tCarteActive [ pas ] = 1 ;
}
printf ( " Merci pour votre achat. Nous vous offrons 5%% supplémentaires. De plus, votre carte est active. \n " ) ;
if ( pointsCarte > 50 & & pointsCarte < 100 )
}
{
else
tPointsCarte [ pas ] = pointsCarte + pointsCarte * ( 1 + ( 10 / 100.0 ) ) ;
if ( pointsCarte > 50 & & pointsCarte < = 100 )
tCarteActive [ pas ] = 1 ;
{
printf ( " Merci pour votre achat. Nous vous offrons 10%% supplémentaires. De plus, votre carte est active. \n " ) ;
tPointsCarte [ pas ] = pointsCarte + pointsCarte * ( 1 + ( 10 / 100.0 ) ) ;
}
tCarteActive [ pas ] = 1 ;
if ( pointsCarte > 100 )
printf ( " Merci pour votre achat. Nous vous offrons 10%% supplémentaires. De plus, votre carte est active. \n " ) ;
{
}
tPointsCarte [ pas ] = pointsCarte + pointsCarte * ( 1 + ( 15 / 100.0 ) ) ;
else
tCarteActive [ pas ] = 1 ;
if ( pointsCarte > 100 )
printf ( " Merci pour votre achat. Nous vous offrons 15%% supplémentaires. De plus, votre carte est active. \n " ) ;
{
}
tPointsCarte [ pas ] = pointsCarte + pointsCarte * ( 1 + ( 15 / 100.0 ) ) ;
else
tCarteActive [ pas ] = 1 ;
{
printf ( " Merci pour votre achat. Nous vous offrons 15%% supplémentaires. De plus, votre carte est active. \n " ) ;
printf ( " Le nombre de points est incorrect. \n " ) ;
}
printf ( " Veuillez ressaisir le nombre de points a ajouter: " ) ;
else
scanf ( " %d " , & pointsCarte ) ;
{
}
printf ( " Le nombre de points est incorrect. \n " ) ;
printf ( " Veuillez ressaisir le nombre de points a ajouter: " ) ;
scanf ( " %d " , & pointsCarte ) ;
}
}
}
else
else
{
{
printf ( " Ce numéro d'adhérant n'existe pas, veuillez réessayer \n " ) ;
printf ( " Ce numéro d'adhérant n'existe pas, veuillez réessayer \n " ) ;
return - 1 ;
return ;
}
}
}
}
@ -386,7 +420,7 @@ void DebitActivitee(int tNoCarte[], int tCarteActive[], int tNbActivitesJour[],
char reponse ;
char reponse ;
printf ( " Entrez le numéro de la carte de l'adhérent recherché : " ) ;
printf ( " Entrez le numéro de la carte de l'adhérent recherché : " ) ;
scanf ( " %d " , & NoCarte ) ;
scanf ( " %d " , & NoCarte ) ;
pas = rechercheAdher a nt( tNoCarte , nbelem , NoCarte , & trouve ) ;
pas = rechercheAdher e nt( tNoCarte , nbelem , NoCarte , & trouve ) ;
if ( trouve = = 1 )
if ( trouve = = 1 )
{
{
if ( tCarteActive [ pas ] = = 1 )
if ( tCarteActive [ pas ] = = 1 )
@ -421,7 +455,7 @@ void DebitActivitee(int tNoCarte[], int tCarteActive[], int tNbActivitesJour[],
else
else
{
{
printf ( " Ce numéro d'adhérant n'existe pas, veuillez réessayer \n " ) ;
printf ( " Ce numéro d'adhérant n'existe pas, veuillez réessayer \n " ) ;
return - 1 ;
return ;
}
}
}
}
@ -430,7 +464,7 @@ void ModificationActivationCarte(int tNoCarte[], int tCarteActive[], int nbelem)
int NoCarte , trouve , pas ;
int NoCarte , trouve , pas ;
printf ( " Entrez le numéro de la carte de l'adhérent recherché : " ) ;
printf ( " Entrez le numéro de la carte de l'adhérent recherché : " ) ;
scanf ( " %d " , & NoCarte ) ;
scanf ( " %d " , & NoCarte ) ;
pas = rechercheAdher a nt( tNoCarte , nbelem , NoCarte , & trouve ) ;
pas = rechercheAdher e nt( tNoCarte , nbelem , NoCarte , & trouve ) ;
if ( trouve = = 1 )
if ( trouve = = 1 )
{
{
if ( tCarteActive [ pas ] = = 1 )
if ( tCarteActive [ pas ] = = 1 )
@ -447,6 +481,6 @@ void ModificationActivationCarte(int tNoCarte[], int tCarteActive[], int nbelem)
else
else
{
{
printf ( " Ce numéro d'adhérant n'existe pas, veuillez réessayer \n " ) ;
printf ( " Ce numéro d'adhérant n'existe pas, veuillez réessayer \n " ) ;
return - 1 ;
return ;
}
}
}
}