Ajout de fonctions

master
Kyllian CHABANON 2 years ago
parent 7c33b3c693
commit 3f8705459a

63
SAE.c

@ -53,6 +53,25 @@ int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[]
return i;
}
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 ajouterPoints(int tNumCarte[], int tPoints[], int tailleLog)
{
@ -72,12 +91,15 @@ void ajouterPoints(int tNumCarte[], int tPoints[], int tailleLog)
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') {
if (choix == 'n' || choix == 'N')
{
printf("Annulation");
return;
}
else
{
modifierPoints(tNumCarte, tPoints, tailleLog, numCarte, nbPoints);
return;
}
}
@ -99,28 +121,43 @@ int modifierPoints(int tNumCarte[], int tPoints[], int tailleLog, int numCarte,
}
}
int recherche(int tab[], int tailleLog, int valeur, int *trouve)
void modifierAge(int tNumCarte[], int tAge[], int tailleLog)
{
for (int i = 0; i < tailleLog; i++)
int numCarte, age, index, trouve;
char choix;
printf("Entrez le numéro d'adhérent : ");
scanf("%d", &numCarte);
index = recherche(tNumCarte, tailleLog, numCarte, &trouve);
while (trouve == 0)
{
if (tab[i] == valeur)
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 nouvel âge :");
scanf("%d", &age);
while (age <= 0)
{
*trouve = 1;
return i;
printf("Âge non valide. Veuillez réessayer.\nEntrez le nouvel âge : ");
scanf("%d", &age);
}
else if (tab[i] > valeur)
printf("Le nouvel âge du client n°%d est bien %d ? (O/n)", numCarte, age);
scanf("%c%*c", &choix);
if (choix == 'n' || choix == 'N')
{
*trouve = 0;
return i;
printf("Annulation");
return;
}
else
{
tAge[index] = age;
return;
}
*trouve = 0;
return tailleLog;
}
/*
int Sauvegarde(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int nbelem)
{
int i, j;

@ -11,5 +11,7 @@ int CreationAdherent();
int FrequenceCentre();
*/
int modifierPoints(int tNumCarte[], int tPoints[], int tailleLog, int numCarte, int points);
int recherche(int tab[], int tailleLog, int valeur, int *trouve);
int modifierPoints(int tNumCarte[], int tPoints[], int tailleLog, int numCarte, int points);
void modifierAge(int tNumCarte[], int tPoints[], int tailleLog, int nbPoints);
void modifierAge(int tNumCarte[], int tAge[], int tailleLog);
Loading…
Cancel
Save