Merge branch 'master' of https://codefirst.iut.uca.fr/git/lola.chalmin/Algo
commit
ad40b54835
@ -1,73 +1,273 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "fRox.h"
|
#include "fRox.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int Fillvar(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int *tacti, int *tpasseoupas, int *tptsbought, int *tptsbonus, char *tcateg, int tmax)//lis le fichier et met les valeurs dans les tableaux
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
f = fopen("donneeClient.don", "r");
|
||||||
|
if (f == NULL)
|
||||||
|
{
|
||||||
|
printf("Problème d'ouverture du fichier Clients...");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int i = 0;
|
||||||
|
int numAd, age, state, acti, passeoupas, ptsbought, ptsbonus;
|
||||||
|
char categ, fnom[15], fprenom[15];
|
||||||
|
|
||||||
|
fscanf(f, "%6d", &numAd);
|
||||||
|
fscanf(f, "%s", fnom);
|
||||||
|
fscanf(f, "%s", fprenom);
|
||||||
|
fscanf(f, "%2d", &age);
|
||||||
|
fscanf(f, "%d", &state);
|
||||||
|
fscanf(f, "%d", &acti);
|
||||||
|
fscanf(f, "%d", &passeoupas);
|
||||||
|
fscanf(f, "%2d", &ptsbought);
|
||||||
|
fscanf(f, "%2d%*c", &ptsbonus);
|
||||||
|
fscanf(f, "%c", &categ);
|
||||||
|
|
||||||
|
while (!feof(f))
|
||||||
|
{
|
||||||
|
if (i == tmax)
|
||||||
|
{
|
||||||
|
printf("Problème de gestion: trop de clients enregistrés à ce jour");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
tAd[i] = numAd;
|
||||||
|
strcpy(tnom[i], fnom);
|
||||||
|
strcpy(tpnom[i], fprenom);
|
||||||
|
tage[i] = age;
|
||||||
|
tstate[i] = state;
|
||||||
|
tacti[i] = acti;
|
||||||
|
tpasseoupas[i] = passeoupas;
|
||||||
|
tptsbought[i] = ptsbought;
|
||||||
|
tptsbonus[i] = ptsbonus;
|
||||||
|
tcateg[i] = categ;
|
||||||
|
|
||||||
|
i++;
|
||||||
|
|
||||||
|
fscanf(f, "%6d", &numAd);
|
||||||
|
fscanf(f, "%s", fnom);
|
||||||
|
fscanf(f, "%s", fprenom);
|
||||||
|
fscanf(f, "%2d", &age);
|
||||||
|
fscanf(f, "%d", &state);
|
||||||
|
fscanf(f, "%d", &acti);
|
||||||
|
fscanf(f, "%d", &passeoupas);
|
||||||
|
fscanf(f, "%2d", &ptsbought);
|
||||||
|
fscanf(f, "%2d%*c", &ptsbonus);
|
||||||
|
fscanf(f, "%c", &categ);
|
||||||
|
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Fonction recherche, (*coderet = 1 si trouvé, = 0 si pas trouvé.) (*rang = rang a laquel se trouve ou doit se trouver la valeur)
|
//Fonction recherche, (*coderet = 1 si trouvé, = 0 si pas trouvé.) (*rang = rang a laquel se trouve ou doit se trouver la valeur)
|
||||||
void fRecherche(int *tNoClient, int n, int noClient, int *coderet, int *rang)
|
void fRecherche(int *tAd, int n, int noClient, int *coderet, int *rang)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < n; i++)
|
for(i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
if(tNoClient[i] == noClient)
|
if(tAd[i] == noClient)
|
||||||
{
|
{
|
||||||
*coderet = 1;
|
*coderet = 1;
|
||||||
*rang = i;
|
*rang = i;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(tNoClient[i] > noClient)
|
if(tAd[i] > noClient)
|
||||||
|
|
||||||
*rang = i;
|
*rang = i;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Affichage D'UN client avec toutes ses données.
|
//Affichage D'UN client avec toutes ses données.
|
||||||
void fAffichage1Client(int *tNoClient, char *tNomClient, char *tPreClient, int *tAge, char *tStatut, int n, int noClient )
|
void fAffichage1Client(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int n, int noClient )
|
||||||
{
|
{
|
||||||
int i, coderet, rang, trouve, NonTrouve;
|
int i, coderet, rang, trouve, NonTrouve;
|
||||||
|
|
||||||
|
fRecherche(tAd, n, noClient, &coderet, &rang);
|
||||||
fRecherche(tNoClient, n, noClient, &coderet, &rang);
|
|
||||||
|
trouve = coderet;
|
||||||
trouve = coderet;
|
|
||||||
|
while (trouve == 0)
|
||||||
while (trouve == 0)
|
{
|
||||||
{
|
if(coderet == 0)
|
||||||
if(coderet == 0)
|
{
|
||||||
{
|
printf("Le numero client n'a pas été trouvé \n");
|
||||||
printf("Le numero client n'a pas été trouvé \n");
|
printf("Veuillez entrer a nouveau le N° Client ou taper -1 pour annuler\n");
|
||||||
printf("Veuillez entrer a nouveau le N° Client ou taper -1 pour annuler\n");
|
scanf("%d", &NonTrouve);
|
||||||
scanf("%d", &NonTrouve);
|
}
|
||||||
}
|
if(NonTrouve==-1)
|
||||||
if(NonTrouve==-1)
|
return;
|
||||||
return;
|
else
|
||||||
else
|
fRecherche(tAd, n, noClient, &coderet, &rang);
|
||||||
fRecherche(tNoClient, n, noClient, &coderet, &rang);
|
trouve=coderet;
|
||||||
trouve=coderet;
|
}
|
||||||
}
|
printf(" N° Client\t Nom\t Prénom\t Age\t Tarif\n");
|
||||||
printf(" N° Client\t Nom\t Prénom\t Age\t Tarif\n");
|
printf("%d\t %s \t %S\t %d\t %S\n", tAd[rang], tnom[rang], tpnom[rang], tage[rang], tstate[rang]);
|
||||||
printf("%d\t %c%*c \t %c%*c\t %d\t %c\n", tNoClient[rang], tNomClient[rang], tPreClient[rang], tAge[rang], tStatut[rang]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Affichage plusieurs client avec toutes les données
|
//Affichage plusieurs client avec toutes les données
|
||||||
int afficheTous(int *tNoClient, char *tNomClient, char *tPreClient, int *tAge, char *tStatut, int n, int noClient )
|
int afficheTous(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int n, int noClient )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
printf(" N° Client\t Nom\t Prénom\t Age\t Tarif\n");
|
||||||
|
for (int i = 0; i < n; ++i)
|
||||||
|
{
|
||||||
|
printf("%d\t %s\t %s\t %d\t %s\n", tAd, tnom, tpnom, tage, tstate);
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
// calcul du nombre d'entree par jour et l'affiche
|
||||||
|
int affNbmEntree( int *tpasseoupas, int tlog)
|
||||||
{
|
{
|
||||||
int i;
|
int i, nbentre;
|
||||||
printf(" N° Client\t Nom\t Prénom\t Age\t Tarif\n");
|
for( i=0 ; i<tlog ; i++)
|
||||||
for (int i = 0; i < n; ++i)
|
(if( tpasseoupas[i]==1 )
|
||||||
{
|
nbentre += 1;)
|
||||||
printf("%d\t %c%*c\t %c%*c\t %d\t %c%*c\n", tNoClient, tNomClient, tPreClient, tAge, tStatut);
|
printf( "Le nombre d'entrée totale de la journée s'élève a : %d\n", nbentre)
|
||||||
}
|
return nbentre;
|
||||||
}
|
}
|
||||||
|
// fonction comptage activité
|
||||||
|
void cptAct(int *bad, int *muscu, int *foot, int *squa, int * zumba, int chx)
|
||||||
|
{
|
||||||
|
if ( chx == 1)
|
||||||
|
*bad += 1;
|
||||||
|
if ( chx == 2)
|
||||||
|
*muscu += 1;
|
||||||
|
if ( chx == 3)
|
||||||
|
*foot += 1;
|
||||||
|
if ( chx == 4)
|
||||||
|
*squa += 1;
|
||||||
|
if ( chx == 5)
|
||||||
|
*zumba += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Calcul et affiche le nombre d'entrée
|
||||||
|
void affNbParAct(int *tacti, int tlog)
|
||||||
|
{
|
||||||
|
int chx1, chx2, chx3, bad, muscu, foot, squa, zumba, totbad, totmuscu, totfoot, totsqua, totzumba;
|
||||||
|
|
||||||
|
for( i=0; i<tlog ; i++)
|
||||||
|
(chx1 = tacti[i]/100;
|
||||||
|
chx2 = (tacti[i]%100)/10;
|
||||||
|
chx3 = chx2%10;)
|
||||||
|
if ( chx1 != 0 )
|
||||||
|
cptAct( &bad, &muscu, &foot, &squa, &zumba, chx1);
|
||||||
|
totbad = bad;
|
||||||
|
totmuscu = muscu;
|
||||||
|
totfoot = foot;
|
||||||
|
totsqua = squa;
|
||||||
|
totzumba = zumba;
|
||||||
|
if ( chx2 != 0 )
|
||||||
|
cptAct( &bad, &muscu, &foot, &squa, &zumba, chx2);
|
||||||
|
totbad = bad + totbad;
|
||||||
|
totmuscu = muscu + totmuscu;
|
||||||
|
totfoot = foot + totfoot;
|
||||||
|
totsqua = squa + totsqua;
|
||||||
|
totzumba = zumba + totzumba;
|
||||||
|
if ( chx3 != 0 )
|
||||||
|
cptAct( &bad, &muscu, &foot, &squa, &zumba, chx3);
|
||||||
|
totbad = bad + totbad;
|
||||||
|
totmuscu = muscu + totmuscu;
|
||||||
|
totfoot = foot + totfoot;
|
||||||
|
totsqua = squa + totsqua;
|
||||||
|
totzumba = zumba + totzumba;
|
||||||
|
If ( chx1 == 0 && chx2 == 0 && chx3 == 0)
|
||||||
|
(printf("Pas d'activité pour le moment")
|
||||||
|
return;
|
||||||
|
)
|
||||||
|
|
||||||
|
printf("Le nombre d'entrée par activité est de\n");
|
||||||
|
printf("Badminton\t Musculation\t Foot\t Squash\t Zumba\n");
|
||||||
|
printf("%d\t %d\t %d\t %d\t %d\t", totbad, totmuscu, totfoot, totsqua, totzumba);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Fonction suppression d'un client
|
||||||
|
|
||||||
int nbmEntree()
|
void suppr1Client(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int *tacti, int *tpasseoupas, int *tptsbought, int *tptsbonus, char *tcateg, int *n, int tmax)
|
||||||
{
|
{
|
||||||
|
int coderet, rang, noClient, i;
|
||||||
|
char contsuppr, confsupp;
|
||||||
|
|
||||||
|
printf("Entrez le numero client à supprimer");
|
||||||
|
scanf("%d", &noClient);
|
||||||
|
|
||||||
|
fRecherche(tAd, n, noClient, &coderet, &rang);
|
||||||
|
|
||||||
|
if ( coderet == 1 )
|
||||||
|
{
|
||||||
|
printf("Confirmation de la suppression? O/N");
|
||||||
|
scanf("%*c%c%*c", &confsupp)
|
||||||
|
if ( confsupp == 'O')
|
||||||
|
{
|
||||||
|
for ( i = rang ; i < n-1 ; i++)
|
||||||
|
|
||||||
|
tAd[i] = tAd[i+1];
|
||||||
|
tnom[i] = tnom[i+1];
|
||||||
|
tpnom[i] = tpnom[i+1];
|
||||||
|
tage[i] = tage[i+1];
|
||||||
|
tstate[i] = tstate[i+1];
|
||||||
|
tacti[i] = tacti[i+1];
|
||||||
|
tpasseoupas[i] = tpasseoupas[i+1];
|
||||||
|
tptsbought[i] = tptsbought[i+1];
|
||||||
|
tptsbonus[i] = tptsbonus[i+1];
|
||||||
|
tcateg[i] = tcateg[i+1];
|
||||||
|
|
||||||
|
printf("Le client numéro %d a été supprimé", noClient);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while ( coderet == 0 )
|
||||||
|
{
|
||||||
|
{
|
||||||
|
printf("Le numéro client n'est pas trouvé. Voulez-vous continuez? O/N");
|
||||||
|
scanf("%*c%c%*c", &confsuppr);
|
||||||
|
}
|
||||||
|
if( contsuppr == 'O')
|
||||||
|
{
|
||||||
|
printf("Veuillez entrer a nouveau le numéro de carte à supprimer");
|
||||||
|
scanf("%d", &noClient);
|
||||||
|
fRecherche(tAd, n, noClient, &coderet, &rang);
|
||||||
|
|
||||||
|
if ( coderet == 1 )
|
||||||
|
{
|
||||||
|
printf("Confirmation de la suppression? O/N");
|
||||||
|
scanf("%*c%c%*c", &confsupp)
|
||||||
|
if ( confsupp == 'O')
|
||||||
|
{
|
||||||
|
for ( i = rang ; i < n-1 ; i++)
|
||||||
|
|
||||||
|
tAd[i] = tAd[i+1];
|
||||||
|
tnom[i] = tnom[i+1];
|
||||||
|
tpnom[i] = tpnom[i+1];
|
||||||
|
tage[i] = tage[i+1];
|
||||||
|
tstate[i] = tstate[i+1];
|
||||||
|
tacti[i] = tacti[i+1];
|
||||||
|
tpasseoupas[i] = tpasseoupas[i+1];
|
||||||
|
tptsbought[i] = tptsbought[i+1];
|
||||||
|
tptsbonus[i] = tptsbonus[i+1];
|
||||||
|
tcateg[i] = tcateg[i+1];
|
||||||
|
|
||||||
|
printf("Le client numéro %d a été supprimé", noClient);
|
||||||
|
return;}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,8 +1,16 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define TAILLE 500
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
int Fillvar(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int *tacti, int *tpasseoupas, int *tptsbought, int *tptsbonus, char *tcateg, int tmax);//lis le fichier et met les valeurs dans les tableaux
|
||||||
|
void fRecherche(int *tAd, int n, int noClient, int *coderet, int *rang);
|
||||||
|
void fAffichage1Client(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int n, int noClient );
|
||||||
|
int afficheTous(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int n, int noClient );
|
||||||
|
int affNbmEntree( int *tpasseoupas, int tlog);
|
||||||
|
void cptAct(int *bad, int *muscu, int *foot, int *squa, int * zumba, int chx);
|
||||||
|
void affNbParAct(int *tacti, int tlog);
|
||||||
|
void suppr1Client(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int *tacti, int *tpasseoupas, int *tptsbought, int *tptsbonus, char *tcateg, int *n, int tmax);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int fchargement(int *tNoClient, char *tNomClient, char *tPreClient, int *tAge, int *tCActiv, int *tActivite, int *tPasseouPas,int *tPtsBought, int *tPtsBonus, char *tCat, int tmax);
|
|
||||||
void fRecherche(int *tNoClient, int n, int noClient, int *coderet, int *rang);
|
|
||||||
void fAffichage1Client(int *tNoClient, char *tNomClient, char *tPreClient, int *tAge, char *tStatut, int n, int noClient );
|
|
||||||
int afficheTous(int *tNoClient, char *tNomClient, char *tPreClient, int *tAge, char *tStatut, int n, int noClient )
|
|
||||||
|
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include "fRox.h"
|
#include "fRox.h"
|
||||||
|
|
||||||
|
|
||||||
void main(void)
|
int main(void)
|
||||||
{ int *tNoClient, *tAge, toto, *tCActiv, *tActivite, *tPtsBought, *tPtsBonus;
|
{ char nom[15], prenom[15], fnom[15], fprenom[15], bCard, member, categ, recharge, acti1[15], acti2[15], acti3[15];
|
||||||
char *tNomClient, *tPreClient, *tCat;
|
int erreur, numAd, age, state, acti, passeoupas, ptsbought,ptsbonus, numCard, avoiravecevann, testnom, testpnom, found = 0, ptrecharge, nbacti, numacti, s1, s2, s3, m1, m2, m3, f1, f2, f3, b1, b2, b3, z1, z2, z3;
|
||||||
|
|
||||||
toto =fchargement(tNoClient, tNomClient, tPreClient, tAge, tCActiv, tActivite, tActivite, tPtsBought, tPtsBonus, tCat, 500);
|
|
||||||
printf("%d\n", toto);
|
|
||||||
|
|
||||||
|
FILE *f;
|
||||||
|
f = fopen("donneeClient.don","r");
|
||||||
|
if (f==NULL){printf("Erreur ouverture fichier clients"); fclose(f); return -1;}
|
||||||
|
|
||||||
|
erreur = Fillvar(numAd, fnom, prenom, age, state, acti, passeoupas, ptsbought, ptsbonus, categ, 500)//lis le fichier et met les valeurs dans les tableaux
|
||||||
|
;
|
||||||
|
|
||||||
|
suppr1Client(numAd, fnom, prenom, age, state, acti, passeoupas, ptsbought, ptsbonus, categ, erreur, 500);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue