unsigned int pila[1000] = {0};
unsigned int pos = 0;
bool EstaVacia() {
return (bool)!pos;
}
bool EstaLlena() {
return pos==999;
}
bool Push(int Valor) {
if (!EstaLlena())
pila[pos++] = Valor;
else
return false;
return true;
}
signed int Pop() {
if (!EstaVacia())
return pila[--pos];
else
return -1;
}
int main() {
Push(50);
Push(100);
int Value = Pop();
return 0;
}
Programa que crea una pila de 1000 elementos enteros e implementa sus funciones básicas sin usar punteros.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.