Escolar Documentos
Profissional Documentos
Cultura Documentos
h>
#include <stdbool.h>
#define tam_max 10
int pilha[tam_max];
int topo = -1;
void empilha(int valor);
int desempilha();
int retornaTopo();
bool pilhaCheia();
bool pilhaVazia();
bool pilhaCheia(){
return (topo==tam_max-1);
}
bool pilhaVazia(){
return (topo==-1);
}
void empilha(int valor){
system("cls");
if(!pilhaCheia()){
topo++;
pilha[topo] = valor;
printf("EMPILHADO COM SUCESSO! \n");
}
else
printf("PILHA CHEIA!");
getch();
}
int desempilha(){
int s=-1;
if(!pilhaVazia()){
s = pilha[topo];
topo--;
}else
printf("PILHA VAZIA!");
return s;
}
int retornaTopo(){
if(!pilhaVazia())
return pilha[topo];
}
int main(){
empilha(6);
empilha(8);
empilha(1);
empilha(13);
empilha(12);
empilha(4);
system("pause");
return 0;
}