12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #include <iostream>
- #include "cStack.h"
- using namespace std;
- cStack::cStack () {top = 0;}
- cStack::~cStack () {
- //clean_stack ();
- }
- void cStack::push (double _var) {
- st [++top] = _var;
- }
- double cStack::pop () {
-
- double last_number = 9999999;
- last_number = st [top];
- st [top] = 0;
- top--;
-
- return last_number;
- }
- int cStack::stack_size () {
- return top;
- }
- void cStack::clean_stack () {
- for (int i = 0; i < MAX_STACK_SIZE; i++) {
- st [i] = 0;
- }
- top = 0;
- }
- void cStack::show_stack () {
-
- cout << "top = " << top << endl;
-
- for (int i = 0; i < MAX_STACK_SIZE; i++ ) {
- cout << "st" << i << " " << st [i] << " ";
- }
- cout << endl;
- }
|