|
|
@ -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;
|
|
|
@ -86,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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -107,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;
|
|
|
@ -131,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");
|
|
|
@ -140,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;
|
|
|
|
|
|
|
|
|
|
|
@ -171,42 +189,30 @@ void affichageCarte(int tabAdhe[], int tabPoints[], int jour[], int mois[], int
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void affichageActivite(int tabCoutPoint[], int tabNbEntree[], int tailleL)
|
|
|
|
void affichageToutActivite(int tabCoutPoint[], int tabNbEntree[], int tailleL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
printf("N°Activité \t Points \t Nombre Entrées \n");
|
|
|
|
printf("N°Activité \t Points \t Nombre Entrées \n");
|
|
|
|
for (i = 0; i < tailleL; i++)
|
|
|
|
for (i = 0; i < tailleL; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (tabCoutPoint[i] != 0)
|
|
|
|
if (tabCoutPoint[i] != 0)
|
|
|
|
printf("%d \t %d \t %d", i, tabCoutPoint[i], tabNbEntree[i]\n);
|
|
|
|
printf("%d \t\t %d \t\t %d\n", i, tabCoutPoint[i], tabNbEntree[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void affichageToutActivite(int tabCoutPoint[], int tabNbEntree[], int tailleL)
|
|
|
|
void affichageActivite(int tabCoutPoint[], int tabNbEntree[], int tailleL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int i, num, trouve = 0;
|
|
|
|
int i, num;
|
|
|
|
printf("Plus d'information de l'activité :");
|
|
|
|
printf("Plus d'information de l'activité :");
|
|
|
|
scanf("%d", &num);
|
|
|
|
scanf("%d", &num);
|
|
|
|
printf("N°Activité \t Points \t Nombre Entrées \n");
|
|
|
|
if (tabCoutPoint[num] == 0)
|
|
|
|
for (i = 0; i < tailleL; i++)
|
|
|
|
printf("Le numéro d'activité n'éxiste pas\n");
|
|
|
|
{
|
|
|
|
else
|
|
|
|
if (i == num)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("%d \t %d \t %d", i, tabCoutPoint[i], tabNbEntree[i]\n);
|
|
|
|
printf("N°Activité \t Points \t Nombre Entrées \n");
|
|
|
|
trouve = 1;
|
|
|
|
printf("%d \t\t %d \t\t %d\n", num, tabCoutPoint[num], tabNbEntree[num]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (trouve == 0)
|
|
|
|
|
|
|
|
printf("Le numéro d'activité n'éxiste pas");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void affichageTest(int tabAdhe[], int nb) {
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
printf("Numéro de carte\n");
|
|
|
|
|
|
|
|
for (i = 0 ; i < nb ; i++) {
|
|
|
|
|
|
|
|
printf("%d\n",tabAdhe[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -228,7 +234,7 @@ void alimenterCarte (int tabAdherent[], int tabPoint[],int nb)
|
|
|
|
int num, trouve, i;
|
|
|
|
int num, trouve, i;
|
|
|
|
char formule;
|
|
|
|
char formule;
|
|
|
|
printf("numero carte :");
|
|
|
|
printf("numero carte :");
|
|
|
|
scanf("%d",&num);
|
|
|
|
scanf("%d%*c",&num);
|
|
|
|
i = recherche(tabAdherent, num, nb, &trouve);
|
|
|
|
i = recherche(tabAdherent, num, nb, &trouve);
|
|
|
|
if (trouve == 1)
|
|
|
|
if (trouve == 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -237,29 +243,29 @@ void alimenterCarte (int tabAdherent[], int tabPoint[],int nb)
|
|
|
|
printf("B : 10€ -> 12 point\n");
|
|
|
|
printf("B : 10€ -> 12 point\n");
|
|
|
|
printf("C : 15€ -> 20 point\n");
|
|
|
|
printf("C : 15€ -> 20 point\n");
|
|
|
|
printf("Choisir :");
|
|
|
|
printf("Choisir :");
|
|
|
|
scanf("%*c%c", &formule);
|
|
|
|
scanf("%c%*c", &formule);
|
|
|
|
while (formule != 'A' || formule != 'B' || formule != 'C')
|
|
|
|
while (formule != 'A' && formule != 'B' && formule != 'C')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("Erreur récupération de donnée\n");
|
|
|
|
printf("Erreur récupération de donnée\n");
|
|
|
|
printf("A : 5€ -> 5 points\n");
|
|
|
|
printf("A : 5€ -> 5 points\n");
|
|
|
|
printf("B : 10€ -> 12 point\n");
|
|
|
|
printf("B : 10€ -> 12 point\n");
|
|
|
|
printf("C : 15€ -> 20 point\n");
|
|
|
|
printf("C : 15€ -> 20 point\n");
|
|
|
|
printf("Choisir :");
|
|
|
|
printf("Choisir :");
|
|
|
|
scanf("%*c%c", &formule);
|
|
|
|
scanf("%c%*c", &formule);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (formule == 'A')
|
|
|
|
if (formule == 'A')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tabAdherent[i] = tabAdherent[i] + 5;
|
|
|
|
tabPoint[i] = tabPoint[i] + 5;
|
|
|
|
printf("accréditation de 5 points\n");
|
|
|
|
printf("accréditation de 5 points\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (formule == 'B')
|
|
|
|
if (formule == 'B')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tabAdherent[i] = tabAdherent[i] + 12;
|
|
|
|
tabPoint[i] = tabPoint[i] + 12;
|
|
|
|
printf("accréditation de 12 points\n");
|
|
|
|
printf("accréditation de 12 points\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (formule == 'C')
|
|
|
|
if (formule == 'C')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
tabAdherent[i] = tabAdherent[i] + 20;
|
|
|
|
tabPoint[i] = tabPoint[i] + 20;
|
|
|
|
printf("accréditation de 20 points\n");
|
|
|
|
printf("accréditation de 20 points\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -280,7 +286,7 @@ void ajoutActivite(int tabCoutPoint[],int tabNbEntree[],int tailleL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("Coût de l'activité :");
|
|
|
|
printf("Coût de l'activité :");
|
|
|
|
scanf("%d", &nbPoint);
|
|
|
|
scanf("%d", &nbPoint);
|
|
|
|
printf("\t Récapitulatif :");
|
|
|
|
printf("\t Récapitulatif \n:");
|
|
|
|
printf("Numéro d'activité : %d\n", num);
|
|
|
|
printf("Numéro d'activité : %d\n", num);
|
|
|
|
printf("Nombre de point : %d\n", nbPoint);
|
|
|
|
printf("Nombre de point : %d\n", nbPoint);
|
|
|
|
tabCoutPoint[num] = nbPoint;
|
|
|
|
tabCoutPoint[num] = nbPoint;
|
|
|
@ -293,7 +299,7 @@ void suppActivite(int tabCoutPoint[], int tabNbEntree[],int tailleL)
|
|
|
|
int num;
|
|
|
|
int num;
|
|
|
|
char choix;
|
|
|
|
char choix;
|
|
|
|
printf("Quel Activité voulez vous supprimer : ");
|
|
|
|
printf("Quel Activité voulez vous supprimer : ");
|
|
|
|
scanf("%d", &num);
|
|
|
|
scanf("%d%*c", &num);
|
|
|
|
if (tabCoutPoint[num] == 0)
|
|
|
|
if (tabCoutPoint[num] == 0)
|
|
|
|
printf("Numéro d'activité pas existant\n");
|
|
|
|
printf("Numéro d'activité pas existant\n");
|
|
|
|
if (tailleL < num)
|
|
|
|
if (tailleL < num)
|
|
|
@ -301,11 +307,11 @@ void suppActivite(int tabCoutPoint[], int tabNbEntree[],int tailleL)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("Êtes vous sûre de vouloir supprimer l'activité (O|N): ");
|
|
|
|
printf("Êtes vous sûre de vouloir supprimer l'activité (O|N): ");
|
|
|
|
scanf("%*c%c", choix);
|
|
|
|
scanf("%c%*c", &choix);
|
|
|
|
while(choix != 'N' || choix != 'O')
|
|
|
|
while(choix != 'N' && choix != 'O')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("Êtes vous sûre de vouloir supprimer l'activité (O|N): ");
|
|
|
|
printf("Êtes vous sûre de vouloir supprimer l'activité (O|N): ");
|
|
|
|
scanf("%*c%c", choix);
|
|
|
|
scanf("%c%*c", &choix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (choix == 'N')
|
|
|
|
if (choix == 'N')
|
|
|
|
printf("Annulation de la suppression\n");
|
|
|
|
printf("Annulation de la suppression\n");
|
|
|
@ -324,7 +330,7 @@ void faireActivite(int tabAdherent[], int tabPoint[],int tabCoutPoint[], int tab
|
|
|
|
int num, idAct, i, trouve;
|
|
|
|
int num, idAct, i, trouve;
|
|
|
|
printf("Identifiant Adhérent : ");
|
|
|
|
printf("Identifiant Adhérent : ");
|
|
|
|
scanf("%d", &num);
|
|
|
|
scanf("%d", &num);
|
|
|
|
i = recherche(tabAdherent, num, tailleLAdhe, &trouve)
|
|
|
|
i = recherche(tabAdherent, num, tailleLAdhe, &trouve);
|
|
|
|
if (trouve == 0)
|
|
|
|
if (trouve == 0)
|
|
|
|
printf("Identifiant Adhérent pas existant\n");
|
|
|
|
printf("Identifiant Adhérent pas existant\n");
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -337,8 +343,11 @@ void faireActivite(int tabAdherent[], int tabPoint[],int tabCoutPoint[], int tab
|
|
|
|
printf("Numéro d'activité que vous voulez pratiquer : ");
|
|
|
|
printf("Numéro d'activité que vous voulez pratiquer : ");
|
|
|
|
scanf("%d", &idAct);
|
|
|
|
scanf("%d", &idAct);
|
|
|
|
if (idAct == -1)
|
|
|
|
if (idAct == -1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("annulation réservation Activité !\n")
|
|
|
|
exit(1);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if (tabCoutPoint[idAct] > tabPoint[i])
|
|
|
|
if (tabCoutPoint[idAct] > tabPoint[i])
|
|
|
|
printf("Vous n'avez pas assez de point");
|
|
|
|
printf("Vous n'avez pas assez de point");
|
|
|
|
else{
|
|
|
|
else{
|
|
|
@ -374,8 +383,8 @@ int SauvegardeActivite(int tabCoutPoint[],int tabNbEntree[],int tailleL)
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0 ; i < tailleL ; i++) {
|
|
|
|
for (i = 0 ; i < tailleL ; i++) {
|
|
|
|
if (tabCoutPoint[num] != 0)
|
|
|
|
if (tabCoutPoint[i] != 0)
|
|
|
|
fprintf(flot,"%d %d %d",i, tabCoutPoint[i], tabNbEntree[i]);
|
|
|
|
fprintf(flot,"%d %d %d\n",i, tabCoutPoint[i], tabNbEntree[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(flot);
|
|
|
|
fclose(flot);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|