|
#include<iostream.h>
const int DefaultSize=10;
class Stack
{
private:
int top;
int St[DefaultSize];
int value;
public:
Stack(){ top=-1;}
Boolean isFull();
void push(int);
Boolean isEmpty();
int pop();
void StackEmpty() {cout<<"empty"<<endl;};
void stackFull() {cout<<"full"<<endl;};
void output();
};
inline Bool Stack::isFull()
{
if (top==DefaultSize -1) return TRUE;
else return FALSE;
}
inline Bool Stack::isEmepty() {
if(top== -1) return TRUE;
else return FALSE ;
void Stack::push(int x)
{
if(isFull()) StackFull();
else st[++top] = x;
}
int Stack::pop()
{
inf(isEmpty()) {StackEmpty(); return 0 ;}
value = st[top--];
return value;
}
void Stack::output() {
cout<<"top = "<<top<<endl;
for (int i=0;i<=top;i++)
cout< |