Jvsierra

tad char

Mar 12th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define PILHA_MAX 1000
  4.  
  5. struct TpPilha
  6. {
  7.     int Topo;
  8.     int Pilha[PILHA_MAX];  
  9. };
  10.  
  11. void InicializaPilha(TpPilha &P)
  12. {
  13.     P.Topo = -1;
  14. }
  15.  
  16. int PilhaVazia(int Topo)
  17. {
  18.     return Topo == -1;
  19. }
  20.  
  21. int PilhaCheia(int Topo)
  22. {
  23.     return Topo == PILHA_MAX - 1;
  24. }
  25.  
  26. void Empilha(TpPilha &P, int Ele)
  27. {
  28.     P.Pilha[++P.Topo] = Ele;
  29. }
  30.  
  31. int Desempilha(TpPilha &P)
  32. {
  33.     return P.Pilha[P.Topo--];
  34. }
  35.  
  36. int ElementoTopo(TpPilha P)
  37. {
  38.     return P.Pilha[P.Topo];
  39. }
Add Comment
Please, Sign In to add comment