计算机语言里的堆栈是什么意思( 三 )


pst->A[pst->top] = e
}
}
//清空栈
void empty(pStack pst)
{
pst->top = -1
}
//判断栈是否为空
int IsEmpty(pStack pst)
{
if(pst->top == -1)
{
return 0
//cout<<"The Stack is empty!"<<endl
}
else
{
return 1
//cout<<"The Stack is not empty!"<<endl
}
}
//判断栈是否为满
int IsFull(pStack pst)
{
if(pst->top == N-1)
{
return 0
}
else
{
return 1
}
}
//初始化栈
void InitStack(pStack pst)
{
pst->top = -1
}
void main()
{
Stack S
InitStack(&S)
int n
cout<<"How many times do you want to Push:"
cin>>n
for(int i=0 i<n i++)
{
Push(&S)
}
cout<<"How many times do you want to Pop:"
cin>>n
for(i=0 i<n i++)
{
cout<<"The element "<<Pop(&S)<<" is pop"<<endl
}
cout<<"The Stack's stutor:"<<endl
if(IsEmpty(&S) == 0)
{
cout<<"The Stack is empty!"<<endl
}
else
{
cout<<"The Stack is not empty!"<<endl
}

if(IsFull(&S) == 0)
{
cout<<"The Stack is full!"<<endl
}
else
{
cout<<"The Stack is not full!"<<endl
}
empty(&S)
cout<<"The Stack's stutor:"<<endl
if(IsEmpty(&S) == 0)
{
cout<<"The Stack is empty!"<<endl
}
else
{
cout<<"The Stack is not empty!"<<endl
}
}
/
typedef struct Stack{
Stack prior
Stack next
int element
}pStack
//压栈
void Push(pStack pst)
{
if((pst) == NULL)
{
pStack S = (pStack)malloc(sizeof(Stack))
(pst) = S
(pst)->next = NULL
(pst)->prior = NULL
cout<<"Input the PUSH da