|
|
@ -18,7 +18,7 @@ int chargementAdherent(int tabAdherent[], int tabPoints[], int jour[], int mois[
|
|
|
|
fclose(flot);
|
|
|
|
fclose(flot);
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pos = ajouter(tabAdherent,i,adhe,tphys);
|
|
|
|
pos = ajouter(tabAdherent,tabPoints,jour,mois,annee,carte,i,adhe,tphys);
|
|
|
|
if (pos >= 0) {
|
|
|
|
if (pos >= 0) {
|
|
|
|
tabPoints[pos] = points;
|
|
|
|
tabPoints[pos] = points;
|
|
|
|
jour[pos] = valjour;
|
|
|
|
jour[pos] = valjour;
|
|
|
@ -34,6 +34,30 @@ int chargementAdherent(int tabAdherent[], int tabPoints[], int jour[], int mois[
|
|
|
|
return i;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// int chargementActivite(int tabPoint[],int tabNbEntree[], int tphys)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// int num, point, nbEntree, i =0;
|
|
|
|
|
|
|
|
// FILE*flot;
|
|
|
|
|
|
|
|
// flot = fopen("activite.txt","r");
|
|
|
|
|
|
|
|
// fscanf(flot,"%d %d %d",&num, &point, &nbEntree);
|
|
|
|
|
|
|
|
// while(!feof(flot))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// if(i >= tphys)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// printf("tableau plein\n");
|
|
|
|
|
|
|
|
// fclose(flot);
|
|
|
|
|
|
|
|
// return -1;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// tabPoint[num] = point;
|
|
|
|
|
|
|
|
// tabNbEntree[num] = nbEntree;
|
|
|
|
|
|
|
|
// i = i + 1;
|
|
|
|
|
|
|
|
// fscanf(flot,"%d %d %d",&num, &point, &nbEntree);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// fclose(flot);
|
|
|
|
|
|
|
|
// return i;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int recherche(int tabTri[], int val, int nb, int *trouve){
|
|
|
|
int recherche(int tabTri[], int val, int nb, int *trouve){
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
*trouve = 0;
|
|
|
|
*trouve = 0;
|
|
|
@ -62,19 +86,24 @@ void decalageGauche(int tabTri[], int nb, int pos) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ajouter(int tab[], int nb, int val, int tphys) {
|
|
|
|
int ajouter(int tabAdhe[], int tabPoints[], int jour[], int mois[], int annee[], int carte[], int nb, int val, int tmax) {
|
|
|
|
int pos, trouve;
|
|
|
|
int pos, trouve;
|
|
|
|
if (nb == tphys) {
|
|
|
|
if (nb == tmax) {
|
|
|
|
printf("Impossible d'insérer un nouvel élément, le tableau est plein !\n");
|
|
|
|
printf("Impossible d'insérer un nouvel élément, le tableau est plein !\n");
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pos = recherche(tab, val, nb, &trouve);
|
|
|
|
pos = recherche(tabAdhe, val, nb, &trouve);
|
|
|
|
if (trouve == 1) {
|
|
|
|
if (trouve == 1) {
|
|
|
|
printf("Valeur déjà présente dans le tableau !\n");
|
|
|
|
printf("Valeur déjà présente dans le tableau !\n");
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
decalageDroite(tab, nb, pos);
|
|
|
|
decalageDroite(tabAdhe, nb, pos);
|
|
|
|
tab[pos] = val;
|
|
|
|
decalageDroite(tabPoints, nb, pos);
|
|
|
|
|
|
|
|
decalageDroite(jour, nb, pos);
|
|
|
|
|
|
|
|
decalageDroite(mois, nb, pos);
|
|
|
|
|
|
|
|
decalageDroite(annee, nb, pos);
|
|
|
|
|
|
|
|
decalageDroite(carte, nb, pos);
|
|
|
|
|
|
|
|
tabAdhe[pos] = val;
|
|
|
|
return pos;
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -83,7 +112,7 @@ int ajouterAdherent(int tabAdhe[], int tabPoints[], int jour[], int mois[], int
|
|
|
|
printf("Nouveau numéro de carte : ");
|
|
|
|
printf("Nouveau numéro de carte : ");
|
|
|
|
scanf("%d",&val);
|
|
|
|
scanf("%d",&val);
|
|
|
|
pos = recherche(tabAdhe, val, nb, &trouve);
|
|
|
|
pos = recherche(tabAdhe, val, nb, &trouve);
|
|
|
|
coderetour = ajouter(tabAdhe, nb, val, tmax);
|
|
|
|
coderetour = ajouter(tabAdhe, tabPoints, jour, mois, annee, carte, nb, val, tmax);
|
|
|
|
if (coderetour == -1) {
|
|
|
|
if (coderetour == -1) {
|
|
|
|
printf("Erreur ajout du nouvel élement !\n");
|
|
|
|
printf("Erreur ajout du nouvel élement !\n");
|
|
|
|
return nb;
|
|
|
|
return nb;
|
|
|
@ -107,7 +136,16 @@ int ajouterAdherent(int tabAdhe[], int tabPoints[], int jour[], int mois[], int
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int suppression(int tab[], int tabPoints[], int nb, int val) {
|
|
|
|
int supprimerAdherent(int tabAdhe[], int tabPoints[], int jour[], int mois[], int annee[], int carte[], int tailleL) {
|
|
|
|
|
|
|
|
int numAdhe;
|
|
|
|
|
|
|
|
printf("Numéro de l'adhérent à supprimer ?\n");
|
|
|
|
|
|
|
|
scanf("%d",&numAdhe);
|
|
|
|
|
|
|
|
tailleL=suppression(tabAdhe,tabPoints,jour,mois,annee,carte,tailleL,numAdhe);
|
|
|
|
|
|
|
|
return tailleL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int suppression(int tab[], int tabPoints[], int jour[], int mois[], int annee[], int carte[],int nb, int val) {
|
|
|
|
int pos, trouve;
|
|
|
|
int pos, trouve;
|
|
|
|
if (nb == 0) {
|
|
|
|
if (nb == 0) {
|
|
|
|
printf("Aucun élément à supprimer dans le tableau !\n");
|
|
|
|
printf("Aucun élément à supprimer dans le tableau !\n");
|
|
|
@ -116,6 +154,10 @@ int suppression(int tab[], int tabPoints[], int nb, int val) {
|
|
|
|
pos = recherche(tab, val, nb, &trouve);
|
|
|
|
pos = recherche(tab, val, nb, &trouve);
|
|
|
|
decalageGauche(tab, nb, pos);
|
|
|
|
decalageGauche(tab, nb, pos);
|
|
|
|
decalageGauche(tabPoints, nb, pos);
|
|
|
|
decalageGauche(tabPoints, nb, pos);
|
|
|
|
|
|
|
|
decalageGauche(jour, nb, pos);
|
|
|
|
|
|
|
|
decalageGauche(mois, nb, pos);
|
|
|
|
|
|
|
|
decalageGauche(annee, nb, pos);
|
|
|
|
|
|
|
|
decalageGauche(carte,nb,pos);
|
|
|
|
nb -= 1;
|
|
|
|
nb -= 1;
|
|
|
|
return nb;
|
|
|
|
return nb;
|
|
|
|
|
|
|
|
|
|
|
@ -147,42 +189,50 @@ void affichageCarte(int tabAdhe[], int tabPoints[], int jour[], int mois[], int
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// void affichageActivite(int tabCoutPoint[], int tabNbEntree[], int tailleL)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// int i;
|
|
|
|
|
|
|
|
// printf("N°Activité \t Points \t Nombre Entrées \n");
|
|
|
|
|
|
|
|
// for (i = 0; i < tailleL; i++)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// if (tabCoutPoint[i] != 0)
|
|
|
|
|
|
|
|
// printf("%d \t %d \t %d", i, tabCoutPoint[i], tabNbEntree[i]\n);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
int chargementActivite(int tabPoint[],int tabNbEntree[], int tphys)
|
|
|
|
// void affichageToutActivite(int tabCoutPoint[], int tabNbEntree[], int tailleL)
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
int num, point, nbEntree, i =0;
|
|
|
|
// int i, num, trouve = 0;
|
|
|
|
FILE*flot;
|
|
|
|
// printf("Plus d'information de l'activité :");
|
|
|
|
flot = fopen("activite.txt","r");
|
|
|
|
// scanf("%d", &num);
|
|
|
|
fscanf(flot,"%d %d %d",&num, &point, &nbEntree);
|
|
|
|
// printf("N°Activité \t Points \t Nombre Entrées \n");
|
|
|
|
while(!feof(flot))
|
|
|
|
// for (i = 0; i < tailleL; i++)
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
if(i < tphys)
|
|
|
|
// if (i == num)
|
|
|
|
{
|
|
|
|
// {
|
|
|
|
printf("tableau plein\n");
|
|
|
|
// printf("%d \t %d \t %d", i, tabCoutPoint[i], tabNbEntree[i]\n);
|
|
|
|
fclose(flot);
|
|
|
|
// trouve = 1;
|
|
|
|
return i;
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
tabPoint[num] = point;
|
|
|
|
// if (trouve == 0)
|
|
|
|
tabNbEntree[num] = nbEntree;
|
|
|
|
// printf("Le numéro d'activité n'éxiste pas");
|
|
|
|
i = i + 1;
|
|
|
|
|
|
|
|
fscanf(flot,"%d %d %d",&num, &point, &nbEntree);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(flot);
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void afficheNbEntreAct(int tabNbEntree[], int tabPoint[], int tphys)
|
|
|
|
// }
|
|
|
|
{
|
|
|
|
|
|
|
|
int num;
|
|
|
|
|
|
|
|
printf("numero d’activité :");
|
|
|
|
|
|
|
|
scanf("%d",&num);
|
|
|
|
// void afficheNbEntreAct(int tabNbEntree[], int tabCoutPoint[], int tphys)
|
|
|
|
if (tabPoint[num] == 0 && tabNbEntree[num] == 0)
|
|
|
|
// {
|
|
|
|
printf("Activité inexistante\n");
|
|
|
|
// int num;
|
|
|
|
else
|
|
|
|
// printf("numero d’activité :");
|
|
|
|
printf("Nombre d’entrée : %d", tabNbEntree[num]);
|
|
|
|
// scanf("%d",&num);
|
|
|
|
|
|
|
|
// if (tabCoutPoint[num] == 0 && tabNbEntree[num] == 0)
|
|
|
|
|
|
|
|
// printf("Activité inexistante\n");
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// printf("Nombre d’entrée : %d", tabNbEntree[num]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
void alimenterCarte (int tabAdherent[], int tabPoint[],int nb)
|
|
|
|
void alimenterCarte (int tabAdherent[], int tabPoint[],int nb)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -218,7 +268,7 @@ void alimenterCarte (int tabAdherent[], int tabPoint[],int nb)
|
|
|
|
tabAdherent[i] = tabAdherent[i] + 12;
|
|
|
|
tabAdherent[i] = tabAdherent[i] + 12;
|
|
|
|
printf("accréditation de 12 points\n");
|
|
|
|
printf("accréditation de 12 points\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (formule == 'B')
|
|
|
|
if (formule == 'C')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tabAdherent[i] = tabAdherent[i] + 20;
|
|
|
|
tabAdherent[i] = tabAdherent[i] + 20;
|
|
|
|
printf("accréditation de 20 points\n");
|
|
|
|
printf("accréditation de 20 points\n");
|
|
|
@ -228,8 +278,89 @@ void alimenterCarte (int tabAdherent[], int tabPoint[],int nb)
|
|
|
|
printf("Erreur ! Numéro de carte absente de la base de donnée\n");
|
|
|
|
printf("Erreur ! Numéro de carte absente de la base de donnée\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// void ajoutActivite(int tabCoutPoint[],int tabNbEntree[],int tailleL)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// int num, nbPoint;
|
|
|
|
|
|
|
|
// printf("Numéro de la Nouvelle Activité :");
|
|
|
|
|
|
|
|
// scanf("%d", &num);
|
|
|
|
|
|
|
|
// if (tabCoutPoint[num] != 0)
|
|
|
|
|
|
|
|
// printf("Numéro d'activité déjà existant.\n");
|
|
|
|
|
|
|
|
// if (tailleL < num)
|
|
|
|
|
|
|
|
// printf("tableau plein");
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// printf("Coût de l'activité :");
|
|
|
|
|
|
|
|
// scanf("%d", &nbPoint);
|
|
|
|
|
|
|
|
// printf("\t Récapitulatif :");
|
|
|
|
|
|
|
|
// printf("Numéro d'activité : %d\n", num);
|
|
|
|
|
|
|
|
// printf("Nombre de point : %d\n", nbPoint);
|
|
|
|
|
|
|
|
// tabCoutPoint[num] = nbPoint;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// void suppActivite(int tabCoutPoint[], int tabNbEntree[],int tailleL)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// int num;
|
|
|
|
|
|
|
|
// char choix;
|
|
|
|
|
|
|
|
// printf("Quel Activité voulez vous supprimer : ");
|
|
|
|
|
|
|
|
// scanf("%d", &num);
|
|
|
|
|
|
|
|
// if (tabCoutPoint[num] == 0)
|
|
|
|
|
|
|
|
// printf("Numéro d'activité pas existant\n");
|
|
|
|
|
|
|
|
// if (tailleL < num)
|
|
|
|
|
|
|
|
// printf("tableau plein\n");
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// printf("Êtes vous sûre de vouloir supprimer l'activité (O|N): ");
|
|
|
|
|
|
|
|
// scanf("%*c%c", choix);
|
|
|
|
|
|
|
|
// while(choix != 'N' || choix != 'O')
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// printf("Êtes vous sûre de vouloir supprimer l'activité (O|N): ");
|
|
|
|
|
|
|
|
// scanf("%*c%c", choix);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (choix == 'N')
|
|
|
|
|
|
|
|
// printf("Annulation de la suppression\n");
|
|
|
|
|
|
|
|
// if (choix == 'O')
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// printf("Suppression Activité %d\n", num);
|
|
|
|
|
|
|
|
// tabCoutPoint[num] = 0;
|
|
|
|
|
|
|
|
// tabNbEntree[num] = 0;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// void faireActivite(int tabAdherent[], int tabPoint[],int tabCoutPoint[], int tabNbEntree[], int tailleLAdhe, int tailleLAct)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// int num, idAct, i, trouve;
|
|
|
|
|
|
|
|
// printf("Identifiant Adhérent : ");
|
|
|
|
|
|
|
|
// scanf("%d", &num);
|
|
|
|
|
|
|
|
// i = recherche(tabAdherent, num, tailleLAdhe, &trouve)
|
|
|
|
|
|
|
|
// if (trouve == 0)
|
|
|
|
|
|
|
|
// printf("Identifiant Adhérent pas existant\n");
|
|
|
|
|
|
|
|
// else
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// printf("Numéro d'activité que vous voulez pratiquer : ");
|
|
|
|
|
|
|
|
// scanf("%d", &idAct);
|
|
|
|
|
|
|
|
// while (tabCoutPoint[idAct] == 0)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// printf("Activité inexistante\n");
|
|
|
|
|
|
|
|
// printf("Numéro d'activité que vous voulez pratiquer : ");
|
|
|
|
|
|
|
|
// scanf("%d", &idAct);
|
|
|
|
|
|
|
|
// if (idAct == -1)
|
|
|
|
|
|
|
|
// exit(1);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (tabCoutPoint[idAct] > tabPoint[i])
|
|
|
|
|
|
|
|
// printf("Vous n'avez pas assez de point");
|
|
|
|
|
|
|
|
// else{
|
|
|
|
|
|
|
|
// tabPoint[i] = tabPoint[i] - tabCoutPoint[idAct];
|
|
|
|
|
|
|
|
// printf("Achat effectué\n");
|
|
|
|
|
|
|
|
// printf("Il vous reste %d point sur votre carte\n", tabPoint[i]);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
int SauvegardeAdherent(int tabAdherent[], int tabPoints[], int jour[], int mois[], int annee[], int carte[], int tailleL) {
|
|
|
|
int SauvegardeAdherent(int tabAdherent[], int tabPoints[], int jour[], int mois[], int annee[], int carte[], int tailleL) {
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
@ -245,5 +376,21 @@ int SauvegardeAdherent(int tabAdherent[], int tabPoints[], int jour[], int mois[
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// int SauvegardeActivite(int tabCoutPoint[],int tabNbEntree[],int tailleL)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// int i;
|
|
|
|
|
|
|
|
// FILE* flot = fopen("activite.txt","w");
|
|
|
|
|
|
|
|
// if (flot == NULL) {
|
|
|
|
|
|
|
|
// printf("Erreur d'ouverture du fichier !\n");
|
|
|
|
|
|
|
|
// return -1;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// for (i = 0 ; i < tailleL ; i++) {
|
|
|
|
|
|
|
|
// if (tabCoutPoint[num] != 0)
|
|
|
|
|
|
|
|
// fprintf(flot,"%d %d %d",i, tabCoutPoint[i], tabNbEntree[i]);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// fclose(flot);
|
|
|
|
|
|
|
|
// return 0;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|