顺序储存
#include<iostream>
using namespace std;
#define MaxSize 10
const ERROR=0;
const TRUE=1;
typedef int ElemType;
typedef struct Snode
{
ElemType data[MaxSize];
int Top;
}Snode;
void Push(Snode *Ptrs,ElemType Item)//入栈
{
if(Ptrs->Top==MaxSize)
{
cout<<"堆栈满";
return ;
}
else
{
Ptrs->data[++(Ptrs->Top)]=Item;
return ;
}
}
ElemType Pop(Snode *Ptrs,)//出栈
{
if(Ptrs->Top==-1)
{
cout<<"堆栈空";
return ERROR;
}
else
{
return (Ptrs->data)[(Ptrs->Top)--];
}
}