#include #include "SAE.h" #define LEN 100 int chargementClients(int* t1, int* t2, int* t3, int tmax){ //charge les tableaux FILE *fe; int numClient, points,ptsDepense; fe=fopen("Adherents.txt","r"); if(fe==NULL){ printf("Probleme ouverture fichier"); return -1;} int i=0; fscanf("%d%*c %d%*c %d%*c",&numClient,&points,&ptsDepense); while(feof(fe)==0){ if(i>tmax){ printf("taille du tableau dépassée \n"); fclose(fe); return-1;} t1[i]=numClient; t2[i]=points; t3[i]=ptsDepense; fscanf("%d%*c %d%*c %d%*c",&numClient,&points,&ptsDepense); i++; } fclose(fe); return i; } int rechercheAdherent(int *t1, int val, int LENlo, int *trouve){//recherche un adherent et affiche sont identifiant int i; for (i=0;i=100){ printf("Vous avez gagné 10pts bonus."); t3[i]=t3[i]-100; t2[i]=t2[i]+10; } } return 0; } void DonneesAdherent(int *t1, int *t2){ int id,trouve,rech,points; printf("Saisir un identifiant:"); scanf("%d",&id); rech=rechercheAdherent(t1,id,LEN,&trouve); points=t2[rech]; printf("Vous êtes l'adhérent %d, et vous avez %d points.",id,points); } void CreditCarte(int *t1, int*t2){ int pts,i,trouve,id; float prix; printf("Saisir identifiant"); scanf("%d",&id); i=rechercheAdherent(t1,id,LEN,&trouve); printf("Saisir un nombre de points(10pts=5€)"); scanf("%d",&pts); while(pts!=0){ prix=pts*0.5; t2[i]=t2[i]+pts; printf("Voulez vous saisir plus de points?(10pts=5€)"); scanf("%d",&pts);} printf("Vous avez acheté %d pts pour %.2f €.",pts,prix); } void NouvelAdherent(void){ int *t1, *t2, *t3, tmax; char ouinon; printf("Voulez-vous créer un nouvel adhérent ? (o/n) : "); //demande de confirmation scanf("%c%*c", &ouinon); if (ouinon=='o'){ chargementClients(*t1, *t2, *t3, tmax); t1[tmax+1] = t1[tmax] +1; t2[tmax+1] = 0; printf("un nouvel adhérent de n°%d à été créé"); } Admin; } void SupprimeAdherent(void){ int *t1, *t2, *t3, tmax, *trouve, pos, i; char ouinon; int ad; printf("Entrez le numéro de l'adhérent à supprimer : "); scanf("%d", &ad); chargementClients(*t1, *t2, *t3, tmax); pos = rechercheAdherent(*t1, ad, tmax, *trouve); if (*trouve=0){printf("erreur, adhérent non trouvé");} else{ printf("la carte à supprimer est la carte n°%d. Souhaitez-vous continuer ? (o/n) : ", ad); scanf("%c%*c", &ouinon); if (ouinon=='o'){ for (i=pos-1; i