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.
194 lines
4.1 KiB
194 lines
4.1 KiB
#include "SAE.h"
|
|
|
|
int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int tmax)
|
|
{
|
|
int i = 0, j = 0;
|
|
int NoCarte, age, pointsCarte, CarteActive;
|
|
int Date, nbActivitesJour;
|
|
FILE *flot, *jour;
|
|
flot = fopen("membres.don", "r");
|
|
jour = fopen("ActivitesJour.don", "r");
|
|
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;
|
|
}
|
|
fscanf(flot, "%d%d%d%d%d%d%d", &NoCarte, &age, &pointsCarte, &CarteActive);
|
|
fscanf(jour, "%d%d", &Date, &nbActivitesJour);
|
|
while(!feof(flot))
|
|
{
|
|
if(i == tmax)
|
|
{
|
|
printf("Tableau plein\n");
|
|
fclose(flot);
|
|
return -1;
|
|
}
|
|
tNoCarte[i] = NoCarte;
|
|
tage[i] = age;
|
|
tPointsCarte[i] = pointsCarte;
|
|
tCarteActive[i] = CarteActive;
|
|
fscanf(flot, "%d%d%d%d", &NoCarte, &age, &pointsCarte, &CarteActive);
|
|
i++;
|
|
}
|
|
while(!feof(jour))
|
|
{
|
|
if(j == tmax)
|
|
{
|
|
printf("Tableau plein\n");
|
|
fclose(jour);
|
|
return -1;
|
|
}
|
|
tDate[j] = Date;
|
|
tNbActivitesJour[j] = nbActivitesJour;
|
|
fscanf(jour, "%d%d", &Date, &nbActivitesJour);
|
|
j++;
|
|
}
|
|
fclose(jour);
|
|
fclose(flot);
|
|
return i;
|
|
}
|
|
|
|
void ajouterPoints(int tNumCarte[], int tPoints[], int tailleLog)
|
|
{
|
|
|
|
int numCarte, nbPoints, trouve, index;
|
|
char choix;
|
|
|
|
printf("Entrez le numéro d'adhérent : ");
|
|
scanf("%d", &numCarte);
|
|
index = recherche(tNumCarte, tailleLog, numCarte, &trouve);
|
|
while (trouve == 0)
|
|
{
|
|
printf("Numéro de carte non trouvé. Veuillez réessayer.\nEntrez le numéro d'adhérent : ");
|
|
scanf("%d", &numCarte);
|
|
index = recherche(tNumCarte, tailleLog, numCarte, &trouve);
|
|
}
|
|
printf("Entrez le nombre de points à ajouter : ");
|
|
scanf("%d", &nbPoints);
|
|
printf("Vous voulez bien ajouter %d points à la carte n°%d ? (O/n)", nbPoints, numCarte);
|
|
scanf("%c%*c", &choix);
|
|
if (choix == 'n' || choix == 'N') {
|
|
printf("Annulation");
|
|
}
|
|
else
|
|
{
|
|
modifierPoints(tNumCarte, tPoints, tailleLog, numCarte, nbPoints);
|
|
}
|
|
}
|
|
|
|
int modifierPoints(int tNumCarte[], int tPoints[], int tailleLog, int numCarte, int nbPoints)
|
|
{
|
|
int index, trouve;
|
|
|
|
index = recherche(tNumCarte, tailleLog, numCarte, &trouve);
|
|
|
|
if (trouve == 0)
|
|
{
|
|
printf("Numéro de carte non trouvé. Annulation de l'opétation.");
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
tPoints[index] += nbPoints;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
int recherche(int tab[], int tailleLog, int valeur, int *trouve)
|
|
{
|
|
for (int i = 0; i < tailleLog; i++)
|
|
{
|
|
if (tab[i] == valeur)
|
|
{
|
|
*trouve = 1;
|
|
return i;
|
|
}
|
|
else if (tab[i] > valeur)
|
|
{
|
|
*trouve = 0;
|
|
return i;
|
|
}
|
|
}
|
|
*trouve = 0;
|
|
return tailleLog;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
void pointsBonus()
|
|
{
|
|
|
|
}
|
|
|
|
void Sauvegarde(int tNoCarte[],int tnom[], int tprenom[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitéesJour[], int nbelem)
|
|
{
|
|
int i;
|
|
FILE *flot;
|
|
flot = fopen("membres.don", "w");
|
|
if(flot == NULL)
|
|
{
|
|
printf("Pb d'ouverture du fichier membres.don\n");
|
|
return -1;
|
|
}
|
|
for(i = 0; i < (nbelem-1); i++)
|
|
{
|
|
fprintf(flot, "%d\t%d\t%d\t%d\t%d\t%d\t%d\n", tNoCarte[i], tnom[i], tprenom[i], tage[i], tPointsCarte[i], tCarteActive[i], tNbActivitéesJour[i]);
|
|
}
|
|
fclose(flot);
|
|
}
|
|
|
|
int rechercheEtCreation(int tNoCarte[], int nbClients)
|
|
{
|
|
int NoCarte, i;
|
|
for( i=0; i < nbClients; i++)
|
|
{
|
|
if(i != tNoCarte[i])
|
|
{
|
|
return i;
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
int CreationAdherents(int tAdherents[], nbClients)
|
|
{
|
|
int NoCarte, nom, prenom, age, pointsCarte, CarteActive, nbActivitéesJour;
|
|
printf("Donnez le nom, le prénom, l'âge du client :\n");
|
|
scanf("%d%d%d", &nom, &prenom, &age);
|
|
pas = rechercheEtCreation(tAdherents, nbClients);
|
|
}
|
|
|
|
int FrequenceCentre()
|
|
{
|
|
|
|
}
|
|
*/
|