1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
| #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int c,k,tel,t,e,i;
float h;
char nom,prenom,type,n,p;
// LES PROTOTYPES
typedef struct client
{
char nom,prenom,type;
int tel;
struct client *suivant;
}t_client;
t_client *estvide(t_client *c);
t_client *ajouter_client(t_client *c,char nom,char prenom,int tel);
t_client *kiem(t_client *c,int k);
t_client *saisie(t_client *c,char nom,char prenom,int tel);
t_client *sup_client(t_client *c,int k);
void typec(t_client *c,float h);
void afficher(t_client *c);
main()
{
t_client *cl;
cl=estvide(cl);
cl=(t_client *)malloc(sizeof(t_client));
cl=saisie(cl,nom,prenom,tel);
afficher(cl);
cl=sup_client(cl,k);
typec(cl,h);
system("pause");
}
// DEFINITION DES FONCTIONS
t_client *estvide(t_client* c)
{
return c=NULL;
}
t_client *ajouter_client(t_client *c,char nom,char prenom,int tel)
{
int e,i,t;
char n,m;
t_client *tmp;
tmp=NULL;
tmp=malloc(sizeof(t_client));
tmp->nom=n;
tmp->prenom=p;
tmp->tel=t;
tmp->suivant=c;
return tmp;
}
t_client *saisie(t_client *c,char nom,char prenom,int tel)
{
printf("\n\nEntrez le nbr de clients a ajouter:");
scanf("%d",&e);
if(e<=0)
{
printf("Aucun client a ajouter\n");
}
else
{
for(i=0;i<e;i++)
{
printf("\n\n\tCLIENT N%d\n\n",i+1);
printf("\nEntrez le nom du client N%d:",i+1);
scanf("%s",&nom);
printf("\nEntrez le prenom du client N%d:",i+1);
scanf("%s",&prenom);
printf("\nEntrez le N de tel du client N%d:",i+1);
scanf("%d",&tel);
}
}
return(c,nom,prenom,tel);
}
t_client *kiem(t_client *c,int k)
{
int p=1;
t_client *tmp;
tmp=c;
while(p<k)
{
tmp=tmp->suivant;
p++;
}
return tmp;
}
t_client *sup_client(t_client *c,int k)
{
kiem(c,k-1)->suivant=kiem(c,k)->suivant;
return c;
}
void typec(t_client *c, float h)
{
printf("Entrez le prix total des achats du client:\n");
scanf("%f",&h);
if(h<100)
{
printf("\nCLIENT OCCASIONNEL\n");
}
else if(h>100 && h<500)
{
printf("\nCLIENT SAISONNIER\n");
}
else if(h<1000 && h>500)
{
printf("\nCLIENT REGULIER\n");
}
else
printf("\nCLIENT FIDEL\n");
}
void afficher(t_client *c)
{
t_client *temp;
temp=c;
printf(" \n\n ");
if(estvide(temp))
printf("La liste est vide.");
else
{
while(temp!=NULL)
{
printf("\nLe Nom: %s",temp->nom);
printf("\nLe prenom: %s",temp->prenom);
printf("\nN de tel: %d",temp->tel);
temp=temp->suivant;
}
}
} |
Partager