#include #include /* Pour exit */ #include "modulePile.h" /**********************************************************************/ pile creerPile(void) { pile p; int i; p.taille = SIZE; p.nbElems = 0; return p; } /**********************************************************************/ pile copierPile(pile p) { return p; /* Copie champs a champ lors du retour de fonction */ } /**********************************************************************/ void afficherPile(pile p) { int i; printf("\n"); for(i=p.nbElems-1; i>=0 ; i=i-1) { printf("%d\n",p.tab[i]); } printf("____\n"); } /**********************************************************************/ int estVidePile(pile p) { int returnValue = 0; if (p.nbElems == 0) returnValue=1; return returnValue; } /**********************************************************************/ int estPleinePile(pile p) { int returnValue = 0; if (p.nbElems == p.taille) returnValue=1; return returnValue; } /**********************************************************************/ int sommetPile(pile p) { if (estVidePile(p)) { printf("Pile vide!!!...\n"); exit(1); } return p.tab[p.nbElems-1]; } /**********************************************************************/ int basePile(pile p) { if (estVidePile(p)) { printf("Pile vide!!!...\n"); exit(1); } return p.tab[0]; } /**********************************************************************/ void empilerPile(pile* p, int e) { if (estPleinePile(*p)) { printf("Pile pleine!!!...\n"); exit(1); } (*p).tab[(*p).nbElems] = e; (*p).nbElems = (*p).nbElems + 1; } /**********************************************************************/ void depilerPile(pile* p) { if (estVidePile(*p)) { printf("Pile vide!!!...\n"); exit(1); } (*p).nbElems = (*p).nbElems - 1; }