ajout de la fonction menu et patch de la fonction ouverture

master
IA 2 years ago
parent 7c33b3c693
commit 8ecbc3bf6b

@ -1,10 +1,10 @@
Date nbActivitesJour
12082022 500
5092022 525
7092022 740
8092022 812
9092022 850
10092022 620
11092022 601
12092022 422
13092022 501
01 500
02 550
03 600
04 520
05 500
06 515
07 500
08 612
09 705
10 800

171
SAE.c

@ -1,25 +1,26 @@
#include "SAE.h"
int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int tmax)
int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int tmax, int *pasAct)
{
int i = 0, j = 0;
int pasMembres, pasAct;
pasMembres = OuvertureMembres(tNoCarte, tage, tPointsCarte, tCarteActive, tmax);
pasAct = OuvertureActivitesJour(tNbActivitesJour, tDate, tmax);
*pasAct = pasAct;
return pasMembres
}
int OuvertureMembres(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tmax)
{
int i = 0;
int NoCarte, age, pointsCarte, CarteActive;
int Date, nbActivitesJour;
FILE *flot, *jour;
FILE *flot;
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);
fscanf(flot, "%d%d%d%d", &NoCarte, &age, &pointsCarte, &CarteActive);
while(!feof(flot))
{
if(i == tmax)
@ -32,27 +33,131 @@ int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[]
tage[i] = age;
tPointsCarte[i] = pointsCarte;
tCarteActive[i] = CarteActive;
fscanf(flot, "%d%d%d%d", &NoCarte, &age, &pointsCarte, &CarteActive);
fscanf(flot, "%d%d%d%d", &NoCarte, &age, &pointsCarte, &CarteActive);
i++;
}
fclose(flot);
return i;
}
int OuvertureActivitesJour(int tNbActivitesJour[], int tDate[], int tmax)
{
int i = 0;
int Date, nbActivitesJour;
FILE *jour;
jour = fopen("ActivitesJour.don", "r");
if(jour == NULL)
{
printf("Pb d'ouverture du fichier ActivitesJour.don\n");
return -1;
}
fscanf(jour, "%d%d", &Date, &nbActivitesJour);
while(!feof(jour))
{
if(j == tmax)
if(i == tmax)
{
printf("Tableau plein\n");
fclose(jour);
return -1;
}
tDate[j] = Date;
tNbActivitesJour[j] = nbActivitesJour;
tDate[i] = Date;
tNbActivitesJour[i] = nbActivitesJour;
fscanf(jour, "%d%d", &Date, &nbActivitesJour);
j++;
i++;
}
fclose(jour);
fclose(flot);
return i;
}
int choixMenu(void)
{
int choix;
printf("\t Gestion des matières\n");
printf("1.\taffichage\n");
printf("2.\tAjouter un client\n");
printf("3.\tModifier l'âge d'un client\n");
printf("4.\tsuppression d'un client\n");
printf("5.\tAjout de points sur une carte\n");
printf("6.\tModification de l'état de la carte\n");
printf("7.\tCréditer une activité à une carte\n");
printf("8.\tquitter\n");
printf("\noption choisie :\n");
scanf("%d", &choix);
return choix;
}
void gestionMatieres(void)
{
int tNoCarte[20] = {0}, tage[20] = {0}, tPointsCarte[20] = {0}, tCarteActive[20] = {0};
int tDate[20] = {0}, tNbActivitesJour[20] = {0};
int tmax = 20, nbelem, choix, pasAct;
nbelem = Ouverture(tNoCarte, tage, tPointsCarte, tCarteActive, tNbActivitesJour, tDate, tmax, &pasAct);
if(nbMatieres < 0)
{
printf("Erreur d'ouverture du fichier ou tableau plein !!!\n");
return ;
}
choix = choixMenu();
while(choix != 9)
{
if(choix == 1)
{
affichage(tMatieres, tCoeff, nbMatieres);
}
if(choix == 2)
{
modificationCoefficient(tMatieres, tCoeff, nbMatieres);
}
if(choix == 3)
{
nbMatieres = insertionNewMatiere(tMatieres, tCoeff, nbMatieres, max);
}
if(choix == 4)
{
nbMatieres = suppressionMatiere(tMatieres, tCoeff, nbMatieres);
}
if(choix == 5)
{
MoyenneNotesMatiere(tMatieres, tNotes, tNbNotes, nbMatieres);
}
if(choix == 6)
{
MoyenneEtudiant(tCoeff, tMatieres, tNotes, tNbNotes, nbMatieres);
}
choix = choixMenu();
}
sauvegarde(tMatieres, tCoeff, nbMatieres);
fclose(flot);
exit(1);
}
/*
int Sauvegarde(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int nbelem)
{
int i, j;
FILE *flot, *jour;
flot = fopen("membres.don", "a");
jour = fopen("ActivitesJour.don", "a");
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;
}
for(i = 0; i < (nbelem-1); i++)
{
fprintf(flot, "\t%d\t%d\t\t%d\t\t%d\n", tNoCarte[i], tage[i], tPointsCarte[i], tCarteActive[i]);
}
for(j = 0; j < (nbelem-1); j++)
{
fprintf(jour, "%d\t\t%d\n", tDate[j], tNbActivitesJour[j]);
}
fclose(jour);
fclose(flot);
}
void ajouterPoints(int tNumCarte[], int tPoints[], int tailleLog)
{
@ -118,36 +223,10 @@ int recherche(int tab[], int tailleLog, int valeur, int *trouve)
return tailleLog;
}
/*
int Sauvegarde(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int nbelem)
{
int i, j;
FILE *flot, *jour;
flot = fopen("membres.don", "a");
jour = fopen("ActivitesJour.don", "a");
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;
}
for(i = 0; i < (nbelem-1); i++)
{
fprintf(flot, "\t%d\t%d\t\t%d\t\t%d\n", tNoCarte[i], tage[i], tPointsCarte[i], tCarteActive[i]);
}
for(j = 0; j < (nbelem-1); j++)
{
fprintf(jour, "%d\t\t%d\n", tDate[j], tNbActivitesJour[j]);
}
fclose(jour);
fclose(flot);
}
int ajoutPointsCarte(int tNoCarte[], int tPointsCarte[], int tCarteActive[], int nbelem)
{

@ -1,11 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
int Ouverture(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tNbActivitesJour[], int tDate[], int tmax);
int OuvertureMembres(int tNoCarte[], int tage[], int tPointsCarte[], int tCarteActive[], int tmax);
int OuvertureActivitesJour(int tNbActivitesJour[], int tDate[], int tmax);
void testOuverture(void);
/*
int Sauvegarde();
void testSauvegarde(void);
/*
int pointsBonus();
int CreationAdherent();
int FrequenceCentre();

BIN
exe

Binary file not shown.

@ -1,10 +1,9 @@
Ncarte age pointsCarte carteActive
1 22 10 0
2 25 5 1
3 47 7 1
4 38 8 1
5 18 8 1
6 46 6 1
7 36 6 0
8 19 2 1
9 21 1 1
1 22 10 0
2 25 5 1
3 47 7 1
4 38 8 1
5 18 8 1
6 46 6 1
7 36 6 0
8 19 2 1
9 21 1 1

@ -2,26 +2,28 @@
void testOuverture(void)
{
int tNoCarte[500] = {0}, tage[500] = {0}, tPointsCarte[500] = {0}, tCarteActive[500] = {0};
int tDate[500] = {0}, tNbActivitesJour[500] = {0};
int tmax = 500, pas, i;
pas = Ouverture(tNoCarte, tage, tPointsCarte, tCarteActive, tNbActivitesJour, tDate, tmax);
printf("Pas: %d", &pas);
printf("Ncarte age pointsCarte carteActive nbActivitesJour Date taillemax\n");
for(i=0; i < pas; i++)
printf("\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", tNoCarte[i], tage[i], tPointsCarte[i], tCarteActive[i], tNbActivitesJour[i], tDate[i], &tmax);
int tNoCarte[20] = {0}, tage[20] = {0}, tPointsCarte[20] = {0}, tCarteActive[20] = {0};
int tDate[20] = {0}, tNbActivitesJour[20] = {0};
int tmax = 20, pasMembres, pasAct, i;
pasMembres = OuvertureMembres(tNoCarte, tage, tPointsCarte, tCarteActive, tmax);
pasAct = OuvertureActivitesJour(tNbActivitesJour, tDate, tmax);
printf("Pas membre: %d\nPas Act : %d\n", &pasMembres, &pasAct);
printf("Ncarte age pointsCarte carteActive nbActivitesJour Date taillemax\n");
for(i=0; i < pasMembres; i++)
printf("%d\t%d\t%d\t%d\t\t%d\t\t%d\t%d\n", tNoCarte[i], tage[i], tPointsCarte[i], tCarteActive[i], tNbActivitesJour[i], tDate[i], tmax);
}
/*
void testSauvegarde(void)
{
int tNoCarte[500] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, tage[500] = {22, 25, 47, 38, 18, 46, 36, 19, 21, 30}, tPointsCarte[500] = {10, 5, 7, 8, 8, 6, 6, 2, 1, 4}, tCarteActive[500] = {0, 1, 1, 1, 1, 1, 0, 1, 1, 1};
int tDate[500] = {12082022, 5092022, 7092022, 8092022, 9092022, 10092022, 11092022, 12092022, 13092022, 14092022}, tNbActivitesJour[500] = {500, 525, 740, 812, 850, 620, 601, 422, 501, 520};
Sauvegarde(tNoCarte, tage, tPointsCarte, tCarteActive, tNbActivitesJour, tDate, 10);
}
*/
int main(void)
{
//testOuverture();
testSauvegarde();
testOuverture();
//testSauvegarde();
return 0;
}
Loading…
Cancel
Save