-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStack.cpp
More file actions
122 lines (122 loc) · 1.96 KB
/
Stack.cpp
File metadata and controls
122 lines (122 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//#include<iostream>
//#include<iomanip>
//using namespace std;
//
//
//template <class T>
//class Stack
//{
//private:
// T* data;
// int top;
// const int MAX_SIZE;
//
//public:
// Stack(const int MAX_SIZE = 0);
// ~Stack();
//
// void push(T newItem);
// T pop();
// T Top();
// void clear();
//
// bool isEmpty() const;
// bool isFull() const;
// void showStructure() const;
//};
//
//
//template<typename T>
//Stack<T>::Stack(const int MAX_SIZE):MAX_SIZE(MAX_SIZE)
//{
// top = -1;
// data = new T[MAX_SIZE];
//}
//
//template<typename T>
//Stack<T>::~Stack()
//{
// if (data != NULL)
// delete[] data;
// data = NULL;
// top = -1;
//}
//
//template<typename T>
//void Stack<T>::push(T newItem)
//{
// if (isFull() == false)
// data[++top] = newItem;
// else
// cout << "Stack is Full\n";
//}
//
//template<typename T>
//T Stack<T>::pop()
//{
// if (isEmpty() == false)
// return data[top--];
// else
// cout << "Stack is Empty\n";
//}
//
//template<typename T>
//T Stack<T>::Top()
//{
// if(isEmpty()==false)
// return data[top];
//}
//
//template<typename T>
//void Stack<T>::clear()
//{
// top = -1;
//}
//
//template<typename T>
//bool Stack<T>::isEmpty() const
//{
// if (top == -1)
// return true;
// return false;
//}
//
//
//template<typename T>
//bool Stack<T>::isFull() const
//{
// if (top == (MAX_SIZE - 1))
// return true;
// return false;
//}
//
//template<typename T>
//void Stack<T> :: showStructure() const
//{
// cout << "top --> ";
// for (int i = top; i >= 0; i--)
// cout << setw(4)<< data[i]<<"\n\t";
// cout << endl;
//
//}
//
//
//int main()
//{
// int n = 5;
// Stack<double> stack(n);
// stack.push(5.0);
// stack.push(6.5);
// stack.showStructure();
//
// stack.push(-3.0);
// stack.push(-8.0);
// stack.showStructure();
//
// stack.pop();
// stack.pop();
// stack.showStructure();
//
// stack.clear();
// stack.showStructure();
//}