parent
c9f4373a47
commit
6356642a7f
@ -0,0 +1,2 @@
|
||||
100 P J 52 1 42
|
||||
101 D F 18 0 51
|
@ -0,0 +1,88 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "sae.h"
|
||||
|
||||
int creeadherent(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int Tmax)
|
||||
{
|
||||
int NC,N,PR,A,CA,PO, i=0;
|
||||
FILE *fe;
|
||||
fe=fopen("adherent.txt","r");
|
||||
if(fe == NULL)
|
||||
{
|
||||
printf("pbouvrfichier\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fscanf(fe,"%d %s %s %d %d %d",&NC,&N,&PR,&A,&CA,&PO);
|
||||
while (!feof(fe))
|
||||
{
|
||||
if(i==Tmax)
|
||||
{
|
||||
printf("%d \t %d\n",i, Tmax);
|
||||
printf("capasité atteinte\n");
|
||||
fclose(fe);
|
||||
return -1;
|
||||
}
|
||||
tNC[i]=NC;
|
||||
tN[i]=N;
|
||||
tPR[i]=PR;
|
||||
tA[i]=A;
|
||||
tCA[i]=CA;
|
||||
tPO[i]=PO;
|
||||
i++;
|
||||
fscanf(fe,"%d %s %s %d %d %d",&NC,&N,&PR,&A,&CA,&PO);
|
||||
}
|
||||
fclose(fe);
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void affichageA(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int n)
|
||||
{
|
||||
int i;
|
||||
printf("----------------------------------------------------------------------------\n");
|
||||
printf("n°client nom\t prenom\t age\t carte\t point\n");
|
||||
for (i=0;i<n;i++)
|
||||
{
|
||||
printf("%d\t %c\t %c\t %d\t %d\t %d\n",tNC[i],tN[i],tPR[i],tA[i],tCA[i],tPO[i]);
|
||||
}
|
||||
printf("----------------------------------------------------------------------------\n");
|
||||
}
|
||||
|
||||
int recherche(int*tNC,int n, int val, int* trouve)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
if (tNC[i]==val)
|
||||
{
|
||||
printf("le valeur %d est trouvé, sa position est %d\n",val,i);
|
||||
*trouve=1;
|
||||
return i;
|
||||
}
|
||||
if(val<tNC[i])
|
||||
{
|
||||
printf("le valeur %d n'est pas trouvé, son position d'insertion est %d\n",val,i);
|
||||
*trouve=0;
|
||||
return i;
|
||||
}
|
||||
|
||||
}
|
||||
printf("le valeur %d n'est pas trouvé, sa position d'insertion est %d\n",val,i);
|
||||
*trouve=0;
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void globale()
|
||||
{
|
||||
int n,valtrouve,trouve,tmax=50;
|
||||
int tNC[50],tA[50],tCA[50],tPO[50];
|
||||
char tN[50],tPR[50];
|
||||
n=creeadherent(tNC,tN,tPR,tA,tCA,tPO,250);
|
||||
affichageA(tNC,tN,tPR,tA,tCA,tPO, n);
|
||||
valtrouve=recherche(tNC,n,100,&trouve);
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/* \file: sae.h
|
||||
\author: Nolan Devouassoux, Renaud Beuret
|
||||
\date: 25 oct
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
\brief: gestion adhèrent
|
||||
*/
|
||||
int creeadherent(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int Tmax);
|
||||
|
||||
/*
|
||||
\brief: affiche les adèrent
|
||||
*/
|
||||
void affichageA(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int n);
|
||||
|
||||
/*
|
||||
\brief: fonction qui recher le client
|
||||
*/
|
||||
int recherche(int*tNC,int n, int val, int*trouve);
|
||||
|
||||
|
||||
/*
|
||||
\brief: ajoute un adèrent
|
||||
*/
|
||||
int insertpers(int *tNC,char *tN,char *tPR,int *tA,int *tCA,int *tPO, int Tmax);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
\brief: globale
|
||||
*/
|
||||
void globale();
|
Loading…
Reference in new issue