Last active
August 29, 2015 13:56
-
-
Save EliveltonCristiano/9242703 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct pilha { | |
int size; | |
int itens[10]; | |
} Pilha; | |
Pilha* criapilha() { | |
Pilha *pilha = (Pilha*) malloc(sizeof(Pilha)); | |
pilha->size = 0; | |
return pilha; | |
} | |
void pop(Pilha *pilha){ | |
if(pilha->size == 0){ | |
puts("pilha vazia"); | |
} else { | |
printf("item removido: %d\n\n", pilha->itens[--pilha->size]); | |
free(pilha->itens[--pilha->size]); | |
} | |
} | |
void Push(Pilha *pilha, int item){ | |
if (pilha->size == 10 ){ | |
puts("Pilha esta cheia..\n\n"); | |
}else{ | |
pilha->itens[pilha->size++] = item; | |
} | |
} | |
void peek(Pilha *pilha){ | |
if(pilha->size == 0){ | |
puts("pilha vazia"); | |
}else{ | |
printf("o topo da pilha e: %d\n\n", pilha->itens[(pilha->size)- 1]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment