#include<iostream.h>
const int StackSize=100;
template<class DataType>
class SeqStack
{public:
SeqStack(){top=-1;}
~SeqStack(){}
void Push(DataType x){if((top+1)==100) cout<<"空间已满!";top++;data[top]=x;}
DataType Pop(){DataType x;if(top==-1)cout<<"数据已空!";top--;x=data[top];return x;}
DataType GetTop(){if(top==-1) cout<<"数据已空!";else cout<<data[top]<<endl; return 0;}
int Empty(){if(top==-1) return 1;else return 0;}void Show(){for(int i=0;i<=top;i++) cout<<data[i]<<" ";cout<<endl;}
private:
DataType data[StackSize];
int top;
};
int main()
{SeqStack<int> S;int i;void caidan();
do
{
caidan();cout<<"Please enter your chioce:";cin>>i;
switch(i)
{case 1:cout<<"please eneter the number you want to push:";
int n;cin>>n;S.Push(n);break;
case 2:S.Pop();break;
case 3:S.GetTop();break;
case 4:break;case 5:S.Show();break;
default:cout<<"enter error!"<<endl;}}while(i!=4);
return 0;}
void caidan()
{cout<<"1--入栈;"<<endl;
cout<<"2--弹栈;"<<endl;
cout<<"3--取栈顶;"<<endl;
cout<<"4--退出;"<<endl;
cout<<"5--显示."<<endl;}
const int StackSize=100;
template<class DataType>
class SeqStack
{public:
SeqStack(){top=-1;}
~SeqStack(){}
void Push(DataType x){if((top+1)==100) cout<<"空间已满!";top++;data[top]=x;}
DataType Pop(){DataType x;if(top==-1)cout<<"数据已空!";top--;x=data[top];return x;}
DataType GetTop(){if(top==-1) cout<<"数据已空!";else cout<<data[top]<<endl; return 0;}
int Empty(){if(top==-1) return 1;else return 0;}void Show(){for(int i=0;i<=top;i++) cout<<data[i]<<" ";cout<<endl;}
private:
DataType data[StackSize];
int top;
};
int main()
{SeqStack<int> S;int i;void caidan();
do
{
caidan();cout<<"Please enter your chioce:";cin>>i;
switch(i)
{case 1:cout<<"please eneter the number you want to push:";
int n;cin>>n;S.Push(n);break;
case 2:S.Pop();break;
case 3:S.GetTop();break;
case 4:break;case 5:S.Show();break;
default:cout<<"enter error!"<<endl;}}while(i!=4);
return 0;}
void caidan()
{cout<<"1--入栈;"<<endl;
cout<<"2--弹栈;"<<endl;
cout<<"3--取栈顶;"<<endl;
cout<<"4--退出;"<<endl;
cout<<"5--显示."<<endl;}