Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define PILHA_MAX 1000
- struct TpPilha
- {
- int Topo;
- int Pilha[PILHA_MAX];
- };
- void InicializaPilha(TpPilha &P)
- {
- P.Topo = -1;
- }
- int PilhaVazia(int Topo)
- {
- return Topo == -1;
- }
- int PilhaCheia(int Topo)
- {
- return Topo == PILHA_MAX - 1;
- }
- void Empilha(TpPilha &P, int Ele)
- {
- P.Pilha[++P.Topo] = Ele;
- }
- int Desempilha(TpPilha &P)
- {
- return P.Pilha[P.Topo--];
- }
- int ElementoTopo(TpPilha P)
- {
- return P.Pilha[P.Topo];
- }
Add Comment
Please, Sign In to add comment