diff --git a/SAE.c b/SAE.c index 03ce7b2..f686673 100644 --- a/SAE.c +++ b/SAE.c @@ -8,21 +8,21 @@ int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[] FILE *flot, *jour; flot = fopen("membres.don", "r"); jour = fopen("ActivitesJour.don", "r"); - if(flot == NULL) + if (flot == NULL) { printf("Pb d'ouverture du fichier membres.don\n"); return -1; } - if(jour == NULL) + 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)) + while (!feof(flot)) { - if(i == tmax) + if (i == tmax) { printf("Tableau plein\n"); fclose(flot); @@ -35,9 +35,9 @@ int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[] fscanf(flot, "%d%d%d%d", &NoCarte, &age, &pointsCarte, &CarteActive); i++; } - while(!feof(jour)) + while (!feof(jour)) { - if(j == tmax) + if (j == tmax) { printf("Tableau plein\n"); fclose(jour); @@ -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) - { - *trouve = 1; - return i; - } - else if (tab[i] > valeur) - { - *trouve = 0; - return i; - } + 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); } - *trouve = 0; - return tailleLog; -} -/* + printf("Entrez le nouvel âge :"); + scanf("%d", &age); + while (age <= 0) + { + printf("Âge non valide. Veuillez réessayer.\nEntrez le nouvel âge : "); + scanf("%d", &age); + } + printf("Le nouvel âge du client n°%d est bien %d ? (O/n)", numCarte, age); + scanf("%c%*c", &choix); + if (choix == 'n' || choix == 'N') + { + printf("Annulation"); + return; + } + else + { + tAge[index] = age; + return; + } +} +/* int Sauvegarde(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int nbelem) { int i, j; @@ -201,7 +238,7 @@ int CreationAdherents(int tNoCarte[], int tage[], int tPointsCarte[], int tCarte tPointsCarte[j] = tPointsCarte[j-1]; tCarteActive[j] = tCarteActive[j-1]; } - tNoCarte[pas] = + tNoCarte[pas] = tMatieres[i]= matieres; tCoeff[i] = coeff; nbMatieres = nbMatieres + 1; diff --git a/SAE.h b/SAE.h index 76bb56a..28adf39 100644 --- a/SAE.h +++ b/SAE.h @@ -11,5 +11,7 @@ int CreationAdherent(); int FrequenceCentre(); */ +int recherche(int tab[], int tailleLog, int valeur, int *trouve); int modifierPoints(int tNumCarte[], int tPoints[], int tailleLog, int numCarte, int points); -int recherche(int tab[], int tailleLog, int valeur, int *trouve); \ No newline at end of file +void modifierAge(int tNumCarte[], int tPoints[], int tailleLog, int nbPoints); +void modifierAge(int tNumCarte[], int tAge[], int tailleLog); \ No newline at end of file