From 649e8bfcf4df6897caa9d802fed5f27aae95d6e6 Mon Sep 17 00:00:00 2001 From: Roxane ROSSETTO Date: Thu, 10 Nov 2022 13:34:34 +0100 Subject: [PATCH] reutilisation des fichiers perso pour faire les tests --- fRox.c | 296 +++++++++++++++++++++++++++++++++++++++++++++--------- fRox.h | 18 +++- testrox | Bin 16960 -> 0 bytes testrox.c | 19 ++-- 4 files changed, 274 insertions(+), 59 deletions(-) delete mode 100755 testrox mode change 100644 => 100755 testrox.c diff --git a/fRox.c b/fRox.c index 4491df7..c114172 100644 --- a/fRox.c +++ b/fRox.c @@ -1,73 +1,273 @@ #include #include "fRox.h" +#include +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) -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; - - for(i = 0; i < n; i++) - { - if(tNoClient[i] == noClient) - { - *coderet = 1; - *rang = i; - return; - } - if(tNoClient[i] > noClient) - - *rang = i; - return; - } + int i; + + for(i = 0; i < n; i++) + { + if(tAd[i] == noClient) + { + *coderet = 1; + *rang = i; + return; + } + if(tAd[i] > noClient) + + *rang = i; + return; + } } //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; - - - fRecherche(tNoClient, n, noClient, &coderet, &rang); - - trouve = coderet; - - while (trouve == 0) - { - if(coderet == 0) - { - printf("Le numero client n'a pas été trouvé \n"); - printf("Veuillez entrer a nouveau le N° Client ou taper -1 pour annuler\n"); - scanf("%d", &NonTrouve); - } - if(NonTrouve==-1) - return; - else - fRecherche(tNoClient, n, noClient, &coderet, &rang); - trouve=coderet; - } - printf(" N° Client\t Nom\t Prénom\t Age\t Tarif\n"); - printf("%d\t %c%*c \t %c%*c\t %d\t %c\n", tNoClient[rang], tNomClient[rang], tPreClient[rang], tAge[rang], tStatut[rang]); + int i, coderet, rang, trouve, NonTrouve; + + fRecherche(tAd, n, noClient, &coderet, &rang); + + trouve = coderet; + + while (trouve == 0) + { + if(coderet == 0) + { + printf("Le numero client n'a pas été trouvé \n"); + printf("Veuillez entrer a nouveau le N° Client ou taper -1 pour annuler\n"); + scanf("%d", &NonTrouve); + } + if(NonTrouve==-1) + return; + else + fRecherche(tAd, n, noClient, &coderet, &rang); + trouve=coderet; + } + 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]); } //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; - printf(" N° Client\t Nom\t Prénom\t Age\t Tarif\n"); - for (int i = 0; i < n; ++i) - { - printf("%d\t %c%*c\t %c%*c\t %d\t %c%*c\n", tNoClient, tNomClient, tPreClient, tAge, tStatut); - } + int i, nbentre; + for( i=0 ; i -#define TAILLE 500 +#include + + +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 ) diff --git a/testrox b/testrox deleted file mode 100755 index 79f9a05993cae2a8b025221fcac4c90976f0f8a3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16960 zcmeHOeQZK_9fB~jJ>Q-t%|aC6A=Q6IXB>4UTW`l@TMCi$GN9r)j#P@9RB@9kj&Yni1YzWS zQcmbNrs^xkb_#+pk}t`Y_pC6LU(-mNid{A>7&-1Mh*POn9-j=H_N}VD>GD#i`p>9_ zD^|y%Jxw>Pj)m)E(Rg~Wez3WzzUc-}D&bip$Grf}(<$7zsasUP894CNgPn6WfA8U+ zzu)_-XYc*BK9BlMeW3cthlKn&{e*LHklh~Fw@|V?4qkp=DMQx5JFmM52ak^CWzxaV$+JS#d2NN}0cCVzIRoVklrvDyKsf{d{|x9uXRGw#nQyNaLO(ESRpyTC zL&vJd@*T^qeHW(Oic|QkS?WcJ^ggnm9?wBmyh%FU!k#`Z^;b!!Tg%gM^@Dh6FJ!`H$-11K-*?J5q z+lPtZp0w*JN3-I7xhefRL^uD(KDS-1~UF90-4UoUhrR_KIQg<<;#AIRIE0sjWm7xe(jQqDj* z1LX{qGf>VzIRoVklrvDyKsf{d#SHL!iu_(8-*exh+L+62sTU#fSWC*W`8HmwbbkMl z-cu#vwaFq|75pCL5~Z{Kqf5Dj^vBa&5`MR_d4{d?JBPU|?5pV@%-&26buxKJU3 z3d4fJX6#k15QEBr*JJ#y;x&q&P#s~uLFwG@QRT<)R&x9Q%Gu+AS-Rr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MuF<${_}m|78TF!u)j(NtKt$$#3}bY&+*sg8N0yoPUN}gbRAR` wj;h4d{~-?!?hk+e()Gc8cg8o +#include #include "fRox.h" -void main(void) -{ int *tNoClient, *tAge, toto, *tCActiv, *tActivite, *tPtsBought, *tPtsBonus; - char *tNomClient, *tPreClient, *tCat; - - toto =fchargement(tNoClient, tNomClient, tPreClient, tAge, tCActiv, tActivite, tActivite, tPtsBought, tPtsBonus, tCat, 500); - printf("%d\n", toto); +int main(void) +{ char nom[15], prenom[15], fnom[15], fprenom[15], bCard, member, categ, recharge, acti1[15], acti2[15], acti3[15]; + 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; + 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; }