Ajout de fonctions

master
Kyllian CHABANON 2 years ago
parent c9e68c1bb5
commit fd8c1a4bcc

90
SAE.c

@ -52,6 +52,96 @@ int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[]
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()
{

@ -7,4 +7,8 @@ void testOuverture();
int pointsBonus();
void sauvegarde();
int CreationAdherent();
int FrequenceCentre();*/
int FrequenceCentre();
*/
int modifierPoints(int tNumCarte[], int tPoints[], int tailleLog, int numCarte, int points);
int recherche(int tab[], int tailleLog, int valeur, int *trouve);
Loading…
Cancel
Save