TrouverAdherent corrigé

main
DahmaneYanis 3 years ago
parent 7ee98144cf
commit f3ffc48c7e

Binary file not shown.

@ -61,14 +61,14 @@ void SupprimerAdherent(int *nbAdherents, int tabNoCarte[], int tabEtatCarte[], i
if (trouve == 0) if (trouve == 0)
{ {
printf("\nNumero de carte %d inexistant. Souhaitez vous un affichage detaille des adherents (O/N) : ", cible); printf("\nNumero de carte %d inexistant. Souhaitez vous un affichage detaille des adherents (O/N) : ", cible);
scanf("%*c%c", &rep); scanf(" %c", &rep);
// Verification de la validité de la réponse // Verification de la validité de la réponse
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Souhaitez vous un affichage detaille des adherents (O/N) : "); printf("Reponse incorrecte. Souhaitez vous un affichage detaille des adherents (O/N) : ");
scanf("%*c%c", &rep); scanf(" %c", &rep);
} }
if (rep == 'O') if (rep == 'O')
@ -83,14 +83,14 @@ void SupprimerAdherent(int *nbAdherents, int tabNoCarte[], int tabEtatCarte[], i
{ {
clean clean
printf("Adherent trouve. Voici ses informations :\nNumero de carte : %d\nEtat de la carte : %d\nPoint(s) sur la carte : %d\nConfirmez vous la suppression de l'adherent (O/N) : ", tabNoCarte[indice], tabEtatCarte[indice], tabPointCarte[indice]); printf("Adherent trouve. Voici ses informations :\nNumero de carte : %d\nEtat de la carte : %d\nPoint(s) sur la carte : %d\nConfirmez vous la suppression de l'adherent (O/N) : ", tabNoCarte[indice], tabEtatCarte[indice], tabPointCarte[indice]);
scanf("%*c%c", &rep); scanf(" %c", &rep);
// Verification de la validité de la réponse // Verification de la validité de la réponse
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Confirmez vous la suppression de l'adherent %d (O/N) : ", tabNoCarte[indice]); printf("Reponse incorrecte. Confirmez vous la suppression de l'adherent %d (O/N) : ", tabNoCarte[indice]);
scanf("%*c%c", &rep); scanf(" %c", &rep);
} }
// Suppression de l'adherent // Suppression de l'adherent
if (rep == 'O') if (rep == 'O')
@ -118,14 +118,14 @@ void SupprimerAdherent(int *nbAdherents, int tabNoCarte[], int tabEtatCarte[], i
// Test pour savoir si on supprime encore un adhérent ou si on retourne au menu principal // Test pour savoir si on supprime encore un adhérent ou si on retourne au menu principal
printf("\nSouhaitez vous entrer un autre numero d'adherent (O/N) : "); printf("\nSouhaitez vous entrer un autre numero d'adherent (O/N) : ");
scanf("%*c%c", &rep); scanf(" %c", &rep);
clean clean
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Souhaitez vous entrer un autre numero d'adherent (O/N) : "); printf("Reponse incorrecte. Souhaitez vous entrer un autre numero d'adherent (O/N) : ");
scanf("%*c%c", &rep); scanf(" %c", &rep);
} }
if(rep == 'N') if(rep == 'N')
@ -277,8 +277,9 @@ int TrouverAdherent(int tabNoCarte[], int nbAdherents, int noCarte, int *trouve)
{ {
if (tabNoCarte[i] == noCarte) if (tabNoCarte[i] == noCarte)
{ {
return i;
*trouve = 1; *trouve = 1;
return i;
} }
} }
@ -287,6 +288,7 @@ int TrouverAdherent(int tabNoCarte[], int nbAdherents, int noCarte, int *trouve)
void RechargeCarte(int noCarte, int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[], int nbAdherents) void RechargeCarte(int noCarte, int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[], int nbAdherents)
{ {
clean
char rep; char rep;
int trouve = 0, actif = 1; int trouve = 0, actif = 1;
int indice = TrouverAdherent(tabNoCarte, nbAdherents, noCarte, &trouve); int indice = TrouverAdherent(tabNoCarte, nbAdherents, noCarte, &trouve);
@ -296,14 +298,14 @@ void RechargeCarte(int noCarte, int tabNoCarte[], int tabEtatCarte[], int tabPoi
if (!trouve && indice == -1) if (!trouve && indice == -1)
{ {
printf("Adherent %d introuvable. Souhaitez-vous rechercher un autre adherent (O/N) : ", noCarte); printf("Adherent %d introuvable. Souhaitez-vous rechercher un autre adherent (O/N) : ", noCarte);
scanf(" %c%*c", &rep); scanf(" %c", &rep);
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Souhaitez vous entrer un autre numero d'adherent (O/N) : "); printf("Reponse incorrecte. Souhaitez vous entrer un autre numero d'adherent (O/N) : ");
printf("\nrep : %c\n", rep); printf("\nrep : %c\n", rep);
scanf(" %c%*c", &rep); scanf(" %c", &rep);
printf("\nRep : %c\n", rep); printf("\nRep : %c\n", rep);
} }
@ -316,8 +318,8 @@ void RechargeCarte(int noCarte, int tabNoCarte[], int tabEtatCarte[], int tabPoi
else else
{ {
clean clean
printf("Numéro d'adhérent à recharger : "); printf("Numero d'adherent a recharger : ");
scanf(" %d%*c", &noCarte); scanf(" %d", &noCarte);
indice = TrouverAdherent(tabNoCarte, nbAdherents, noCarte, &trouve); indice = TrouverAdherent(tabNoCarte, nbAdherents, noCarte, &trouve);
} }

@ -10,9 +10,12 @@ int main(void){
int taillePhysique = 15; int taillePhysique = 15;
int tailleLog = 15; int tailleLog = 15;
int trouve = 0;
//int err = AfficheInfosAdherent(15, tabCarte, tabEtat, tabPoint, tailleLog); //int err = AfficheInfosAdherent(15, tabCarte, tabEtat, tabPoint, tailleLog);
SupprimerAdherent(&tailleLog, tabCarte, tabEtat, tabPoint); //SupprimerAdherent(&tailleLog, tabCarte, tabEtat, tabPoint);
//AfficheAdherents(tabCarte, tabEtat, tabPoint, tailleLog); //AfficheAdherents(tabCarte, tabEtat, tabPoint, tailleLog);
//RechargeCarte(30, tabCarte, tabEtat, tabPoint, tailleLog); RechargeCarte(30, tabCarte, tabEtat, tabPoint, tailleLog);
//int indice = TrouverAdherent(tabCarte, tailleLog, 5, &trouve);
//printf("Indice: %d\nTrouve = %d", indice, trouve);
} }
Loading…
Cancel
Save