07/11 Fonctions réalisées

master
Louis LABORIE 2 years ago
parent 7e30ce5b09
commit e7be51a37c

@ -1,7 +1,6 @@
2 18 29 10 2022 1 2 18 29 10 2022 1
14 25 14 05 2007 1 14 25 14 5 2007 1
56 14 11 09 2001 0 23 10 17 7 1789 1
69 5 13 11 2015 1 56 5 13 11 2015 1
77 6 7 01 2015 0 69 6 7 1 2015 0
89 17 14 07 2016 1 77 17 14 7 2016 1

@ -78,6 +78,34 @@ int ajouter(int tab[], int nb, int val, int tphys) {
return pos; return pos;
} }
int ajouterAdherent(int tabAdhe[], int tabPoints[], int jour[], int mois[], int annee[], int carte[], int nb, int tmax) {
int val, trouve, points = 10, valJour, valMois, valAnnee, perdue = 1, pos, coderetour;
printf("Nouveau numéro de carte : ");
scanf("%d",&val);
pos = recherche(tabAdhe, val, nb, &trouve);
coderetour = ajouter(tabAdhe, nb, val, tmax);
if (coderetour == -1) {
printf("Erreur ajout du nouvel élement !\n");
return nb;
}
printf("\nJour : ");
scanf("%d",&valJour);
printf("\nMois : ");
scanf("%d",&valMois);
printf("\nAnnée : ",valAnnee);
scanf("%d",&valAnnee);
tabPoints[pos] = points;
jour[pos] = valJour;
mois[pos] = valMois;
annee[pos] = valAnnee;
carte[pos] = perdue;
nb += 1;
return nb;
}
int suppression(int tab[], int tabPoints[], int nb, int val) { int suppression(int tab[], int tabPoints[], int nb, int val) {
int pos, trouve; int pos, trouve;
@ -203,7 +231,7 @@ void alimenterCarte (int tabAdherent[], int tabPoint[],int nb)
int SauvegardeAdherent(int tabAdherent[], int tailleL) { int SauvegardeAdherent(int tabAdherent[], int tabPoints[], int jour[], int mois[], int annee[], int carte[], int tailleL) {
int i; int i;
FILE* flot = fopen("adherent.txt","w"); FILE* flot = fopen("adherent.txt","w");
if (flot == NULL) { if (flot == NULL) {
@ -211,8 +239,9 @@ int SauvegardeAdherent(int tabAdherent[], int tailleL) {
return -1; return -1;
} }
for (i = 0 ; i < tailleL ; i++) { for (i = 0 ; i < tailleL ; i++) {
fprintf(flot,"%d\n",tabAdherent[i]); fprintf(flot,"%d %d %d %d %d %d\n",tabAdherent[i],tabPoints[i],jour[i],mois[i],annee[i],carte[i]);
} }
fclose(flot);
return 0; return 0;
} }

@ -13,6 +13,8 @@ void decalageGauche(int tabTri[], int nb, int pos);
int ajouter(int tab[], int nb, int val, int tphys); int ajouter(int tab[], int nb, int val, int tphys);
int ajouterAdherent(int tabAdhe[], int tabPoints[], int jour[], int mois[], int annee[], int carte[], int nb, int tmax);
int suppression(int tab[], int tabPoints[], int nb, int val); int suppression(int tab[], int tabPoints[], int nb, int val);
@ -25,5 +27,4 @@ void affichageTous(int tabNumCarte[], int tabPoint[], int carte[], int jour[], i
void affichageCarte(int tabAdhe[], int tabPoints[], int jour[], int mois[], int annee[], int carte[], int nb); void affichageCarte(int tabAdhe[], int tabPoints[], int jour[], int mois[], int annee[], int carte[], int nb);
int SauvegardeAdherent(int tabAdherent[], int tabPoints[], int jour[], int mois[], int annee[], int carte[], int tailleL);
int SauvegardeAdherent(int tabAdherent[], int tailleL);

@ -4,34 +4,35 @@
int main(void) { int main(void) {
int tabAdhe[50], tabPoints[50], jour[50], mois[50], annee[50], carte[50], tailleL; int tabAdhe[50], tabPoints[50], jour[50], mois[50], annee[50], carte[50], tailleL;
// int codeSauv, coderetour=-1; int codeSauv, coderetour=-1;
tailleL=chargementAdherent(tabAdhe,tabPoints,jour,mois,annee,carte,50); tailleL=chargementAdherent(tabAdhe,tabPoints,jour,mois,annee,carte,50);
printf("%d\n",carte[3]);
affichageCarte(tabAdhe,tabPoints,jour,mois,annee,carte,tailleL); affichageCarte(tabAdhe,tabPoints,jour,mois,annee,carte,tailleL);
affichageTous(tabAdhe,tabPoints,jour,mois,annee,carte,tailleL); affichageTous(tabAdhe,tabPoints,jour,mois,annee,carte,tailleL);
ajouterAdherent(tabAdhe,tabPoints,jour,mois,annee,carte,tailleL,50);
affichageCarte(tabAdhe,tabPoints,jour,mois,annee,carte,tailleL);
// affichageInfo(tabAdhe,tabPoints,jour,mois,annee,carte,tailleL); // affichageInfo(tabAdhe,tabPoints,jour,mois,annee,carte,tailleL);
// tailleL=ajouter(tab,tailleL,69,50); // tailleL=ajouter(tab,tailleL,69,50);
// affichageTest(tab,tailleL); // affichageTest(tab,tailleL);
// tailleL=suppression(tab,tailleL,69); // tailleL=suppression(tab,tailleL,69);
// affichageTest(tab,tailleL); // affichageTest(tab,tailleL);
// printf("Sauvegarder ? (1 : Oui, 2 : Non)\n"); printf("Sauvegarder ? (1 : Oui, 2 : Non)\n");
// scanf("%d",&codeSauv); scanf("%d",&codeSauv);
// if (codeSauv == 1) { if (codeSauv == 1) {
// while(coderetour == -1) { while(coderetour == -1) {
// coderetour = SauvegardeAdherent(tab,tailleL); coderetour = SauvegardeAdherent(tabAdhe,tabPoints, jour, mois, annee, carte, tailleL);
// if (coderetour == 0) { if (coderetour == 0) {
// printf("Sauvegarde réussie !\n"); printf("Sauvegarde réussie !\n");
// break; break;
// } }
// else { else {
// printf("Sauvegarde échouée\n"); printf("Sauvegarde échouée\n");
// printf("Réessayer ?(1 : Oui, 2 : Non\n"); printf("Réessayer ?(1 : Oui, 2 : Non\n");
// scanf("%d",&codeSauv); scanf("%d",&codeSauv);
// if (codeSauv == 2) break; if (codeSauv == 2) break;
// } }
// } }
// } }
return 0; return 0;
} }
Loading…
Cancel
Save