You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
3.5 KiB
129 lines
3.5 KiB
#include "Fonctions.h"
|
|
|
|
int rechercheAdherent(int tNoCarte[], int nbelem, int NoCarte, int *trouve)
|
|
{
|
|
int i;
|
|
for(i = 0; i < nbelem; i++)
|
|
{
|
|
if(tNoCarte[i] == NoCarte)
|
|
{
|
|
*trouve = 1;
|
|
return i;
|
|
}
|
|
if(tNoCarte[i] > NoCarte)
|
|
{
|
|
*trouve = 0;
|
|
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.\nLa carte n'est pas active car il n'y a pas de points dessus.\nVoulez-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 ModificationAge(int tNoCarte[], int tage[], int nbelem)
|
|
{
|
|
int pas, NoCarte, age, trouve;
|
|
printf("Entrez le numéro de la carte de l'adhérent recherché : ");
|
|
scanf("%d",&NoCarte);
|
|
pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve);
|
|
if(trouve == 1)
|
|
{
|
|
printf("Entrez l'age de l'adhérent : ");
|
|
scanf("%d",&age);
|
|
tage[pas] = age;
|
|
}
|
|
else
|
|
{
|
|
printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n");
|
|
return;
|
|
}
|
|
}
|
|
|
|
int SupprimmerAdherent(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int nbelem)
|
|
{
|
|
int pas, i, NoCarte, trouve;
|
|
printf("Entrez le numéro de la carte de l'adhérent recherché : ");
|
|
scanf("%d",&NoCarte);
|
|
pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve);
|
|
if(trouve == 1)
|
|
{
|
|
for(i = pas; i < nbelem; i++)
|
|
{
|
|
tNoCarte[i] = tNoCarte[i+1];
|
|
tage[i] = tage[i+1];
|
|
tPointsCarte[i] = tPointsCarte[i+1];
|
|
tCarteActive[i] = tCarteActive[i+1];
|
|
}
|
|
nbelem = nbelem - 1;
|
|
return nbelem;
|
|
}
|
|
else
|
|
{
|
|
printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n");
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
void ModificationActivationCarte(int tNoCarte[], int tCarteActive[], int nbelem)
|
|
{
|
|
int NoCarte, trouve, pas;
|
|
printf("Entrez le numéro de la carte de l'adhérent recherché : ");
|
|
scanf("%d",&NoCarte);
|
|
pas = rechercheAdherent(tNoCarte, nbelem, NoCarte, &trouve);
|
|
if(trouve == 1)
|
|
{
|
|
if(tCarteActive[pas] == 1)
|
|
{
|
|
tCarteActive[pas] = 0;
|
|
printf("La carte est desactivée.\n");
|
|
}
|
|
else
|
|
{
|
|
tCarteActive[pas] = 1;
|
|
printf("La carte est activée.\n");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
printf("Ce numéro d'adhérant n'existe pas, veuillez réessayer\n");
|
|
return;
|
|
}
|
|
} |