Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct noeud
- {
- int donnees;
- struct noeud *suivant;
- };
- struct noeud *avant = NULL;
- struct noeud *arriere = NULL;
- void enfiler(int element)
- {
- struct noeud *nptr = malloc(sizeof(struct noeud));
- nptr->donnees = element;
- nptr->suivant = NULL;
- if (arriere == NULL)
- {
- avant = nptr;
- arriere = nptr;
- }
- else
- {
- arriere->suivant = nptr;
- arriere = arriere->suivant;
- }
- }
- void afficher()
- {
- struct noeud *temp;
- temp = avant;
- printf("\n");
- while (temp != NULL)
- {
- printf("%d\t", temp->donnees);
- temp = temp->suivant;
- }
- }
- void defiler()
- {
- if (avant == NULL)
- {
- printf("\n\nLa file est vide \n");
- }
- else
- {
- struct noeud *temp;
- temp = avant;
- avant = avant->suivant;
- printf("\n\n%d supprime", temp->donnees);
- free(temp);
- }
- }
- int main()
- {
- int n, ch;
- do
- {
- printf("\n\nMenu File\n1. Ajouter \n2. Retirer\n3. Afficher\n0. Quitter");
- printf("\nEntrer votre choix 0-3 ? : ");
- scanf("%d", &ch);
- switch (ch)
- {
- case 1:
- printf("\nEntrer un nombre ");
- scanf("%d", &n);
- enfiler(n);
- break;
- case 2:
- defiler();
- break;
- case 3:
- afficher();
- break;
- }
- }while (ch != 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement