Guest User

Untitled

a guest
Sep 19th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. Pilas.h
  2. #pragma once
  3. #define LongitudMaxima 6
  4. class Pilas
  5. {
  6. private:
  7. int nValor,Tope, nPila[LongitudMaxima];
  8. public:
  9. Pilas();
  10. ~Pilas();
  11. bool EstaVacia();
  12. bool EstaLlena();
  13. bool push(int nValor);
  14. void imprimir();
  15. };
  16.  
  17.  
  18.  
  19. Pilas.ccp
  20. #include "stdafx.h"
  21. #include "Pilas.h"
  22.  
  23.  
  24. Pilas::Pilas()
  25. {
  26. Tope = -1;
  27. for (int nIndex = 0; nIndex < 6; nIndex++)
  28. {
  29. nPila[nIndex] = 0;
  30. }
  31. }
  32.  
  33.  
  34. Pilas::~Pilas()
  35. {
  36. }
  37.  
  38. bool Pilas::EstaVacia()
  39. {
  40. return Tope == -1;
  41. }
  42.  
  43. bool Pilas::EstaLlena()
  44. {
  45. return Tope = nPila[LongitudMaxima];
  46. }
  47.  
  48. bool Pilas::push(int nValor)
  49. {
  50. bool bAllOk = false;
  51. if (!EstaLlena())
  52. {
  53. if (EstaVacia())
  54. {
  55. return true;
  56. Tope = 0;
  57. nPila[0] = nValor;
  58.  
  59. }
  60. else
  61. {
  62. for (int nIndex = 1; nIndex < LongitudMaxima; nIndex++)
  63. {
  64. cout << "LA PILA ESTA LLENA..." << endl;
  65. }
  66.  
  67. }
  68. }
  69. }
  70.  
  71. void Pilas::imprimir()
  72. {
  73. cout << "LA PILA es: " << push(nValor)<< endl;
  74. }
  75.  
  76. // main.cpp: define el punto de entrada de la aplicación de consola.
  77. //
  78.  
  79. #include "stdafx.h"
  80.  
  81.  
  82. int main()
  83. {
  84. Pilas A;
  85. A.imprimir();
  86. system("pause");
  87. return 0;
  88. }
Add Comment
Please, Sign In to add comment