Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Pilas.h
- #pragma once
- #define LongitudMaxima 6
- class Pilas
- {
- private:
- int nValor,Tope, nPila[LongitudMaxima];
- public:
- Pilas();
- ~Pilas();
- bool EstaVacia();
- bool EstaLlena();
- bool push(int nValor);
- void imprimir();
- };
- Pilas.ccp
- #include "stdafx.h"
- #include "Pilas.h"
- Pilas::Pilas()
- {
- Tope = -1;
- for (int nIndex = 0; nIndex < 6; nIndex++)
- {
- nPila[nIndex] = 0;
- }
- }
- Pilas::~Pilas()
- {
- }
- bool Pilas::EstaVacia()
- {
- return Tope == -1;
- }
- bool Pilas::EstaLlena()
- {
- return Tope = nPila[LongitudMaxima];
- }
- bool Pilas::push(int nValor)
- {
- bool bAllOk = false;
- if (!EstaLlena())
- {
- if (EstaVacia())
- {
- return true;
- Tope = 0;
- nPila[0] = nValor;
- }
- else
- {
- for (int nIndex = 1; nIndex < LongitudMaxima; nIndex++)
- {
- cout << "LA PILA ESTA LLENA..." << endl;
- }
- }
- }
- }
- void Pilas::imprimir()
- {
- cout << "LA PILA es: " << push(nValor)<< endl;
- }
- // main.cpp: define el punto de entrada de la aplicación de consola.
- //
- #include "stdafx.h"
- int main()
- {
- Pilas A;
- A.imprimir();
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment