Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- typedef struct
- {
- int code;
- char nom[20];
- }Adherent;
- typedef struct Liste
- {
- Adherent donnee;
- struct Liste *suiv;
- }Liste;
- Liste *new_element()
- {
- Liste *ne;
- ne=(Liste *)malloc(sizeof(Liste));
- ne->suiv=NULL;
- printf("donner le code de l'adherent\n");
- scanf("%d",&ne->donnee.code);
- getchar();
- printf("donner le nom de l'adherent\n");
- gets(ne->donnee.nom);
- return ne;
- }
- Liste *Insertion_Tete(Liste *T,Liste *ne)
- {
- if(T==NULL)
- {
- T=ne;
- }
- else
- {
- ne->suiv=T;
- T=ne;
- }
- return T;
- }
- Liste *Insertion_Queue(Liste *T,Liste *ne)
- {
- Liste *p=T;
- while(p->suiv!=NULL)
- {
- p=p->suiv;
- }
- p->suiv=ne;
- return T;
- }
- void Afficher(Liste *T)
- {
- Liste *p=T;
- while(p!=NULL)
- { printf("le nom:%s le code:%d\n",p->donnee.nom,p->donnee.code);
- p=p->suiv;
- }
- }
- int Rechercher(int cd,Liste *T)
- {
- Liste *p=T;
- while(p!=NULL)
- {
- if(p->donnee.code==cd)
- {
- printf("le nom:%s le code:%d\n",p->donnee.nom,p->donnee.code);
- return 1;
- }
- p=p->suiv;
- }
- printf("n'existe pas\n");
- return 0;
- }
- void modification(Liste *T,int cd)
- {
- char nom_nouv[20];
- Liste *p=T;
- while(p!=NULL)
- {
- if(p->donnee.code==cd)
- {
- printf("le nom:%s le code:%d\n",p->donnee.nom,p->donnee.code);
- printf("le nouveau nom \n");
- gets(nom_nouv);
- strcpy(p->donnee.nom,nom_nouv);
- return ;
- }
- p=p->suiv;
- }
- printf("n'existe pas\n");
- }
- Liste *Suppression(Liste *T,int cd)
- {
- Liste *q=T,*p=T;
- while(p->donnee.code!=cd&&p!=NULL)
- {
- q=p;
- p=p->suiv;
- }
- if(p==NULL)
- {
- printf("n'existe pas\n");
- }
- else if(p->donnee.code==cd)
- {
- if(p==T)
- {
- T=T->suiv;
- p->suiv=NULL;
- free(p);
- }
- else
- {
- q->suiv=p->suiv;
- p->suiv=NULL;
- free(p);
- }
- }
- return T;
- }
- int main()
- { int n=0;
- Liste *T=NULL;
- int *p;
- walo(&n);
- printf("%d!\n",n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement