#include #define MAX 3 //MAX = Quantidade de elementos máximos na pilha /*#include "Fila usando lista encadeada.c"*/ /* void clsMenu(void) //usar quando for mudar o menu { COORD coordScreen = {0, 0}; DWORD cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD dwConSize; HANDLE hConsole=GetStdHandle(STD_OUTPUT_HANDLE); GetConsoleScreenBufferInfo(hConsole, &csbi); dwConSize = csbi.dwSize.X * csbi.dwSize.Y; FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten); GetConsoleScreenBufferInfo(hConsole, &csbi); FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten); SetConsoleCursorPosition(hConsole, coordScreen); } void cls(void) //usar quando não precisar mudar o menu { COORD coordScreen = {0, 3}; DWORD cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD dwConSize; HANDLE hConsole=GetStdHandle(STD_OUTPUT_HANDLE); GetConsoleScreenBufferInfo(hConsole, &csbi); dwConSize = csbi.dwSize.X * csbi.dwSize.Y; FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten); GetConsoleScreenBufferInfo(hConsole, &csbi); FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten); SetConsoleCursorPosition(hConsole, coordScreen); } */ int topo=-1; //Indica o topo da pilha // no_t *lista; int pilha[MAX]; //Declaração da pilha void insere (int p); //Função que insere itens na pilha void remover(void); //Função que remove itens da pilha void exibe (void); //Função que exibe os itens da pilha void exibirlista(void); //chama a função lista/fila /* int main (void) { //lista=cria(lista); int op; for (;;) { system("clear"); //Limpa a tela, somente no Linux //--------------------------------- //MENU PRINCIPAL //--------------------------------- printf("\nMenu"); printf("\n\n1- Insere"); printf("\n2- Remover"); printf("\n3- Exibir pilha"); printf("\n4- Exibir fila"); printf("\n5- Sair"); printf("\n\nEntre a sua opção:"); //--------------------------------- scanf("%d",&op); switch(op) { case 1 : insere(); break; case 2 : remover(); break; case 3 : exibe(); break; case 4: //imprime(lista); break; case 5 : exit(0); default: printf("\nOpção Errada"); getchar(); break; } } } */ void insere (int p) { int controle=0; controle++; int i; topo = topo + 1; if (topo == MAX) //Insere itens na pilha até que topo for diferente de MAX { printf("\nPilha Cheia, colocado na fila\n"); if(controle == 1) { //lista = insini(lista); } else if(controle != 1) { //insere na fila } topo = topo - 1; getchar(); } else { pilha[topo] = p; } } void exibirlista(void) { } void remover (void) { if (topo >= 0) { pilha[topo] = 0; topo = topo - 1; } else { printf("Pilha Vazia"); getchar(); } } void exibe (void) { int x; char s[80]; //printf("lista:", *lista); for (x=0;x<=topo;x++) printf("\n %d",pilha[x]); printf("\n (S)Limpar\n"); scanf("%s",s); // cls(); }