理解并用顺序栈操作运行下列程序:
#include <iostream>
using namespace std;
#include "Status.h"
typedef int ElemType;
#include "SqStack.h"
void main()
{
SqStack S;
ElemType e;
InitStack(S);
Push(S,2);
Push(S,4);
Push(S,6);
Push(S,8);
cout<<"\n由栈底至栈顶的元素为:";
StackTraverse(S);
cout<<"\n栈的长度为:"<<StackLength(S)<<endl;
GetTop(S,e);
cout<<"\n栈顶元素为:"<<e<<endl;
Pop(S,e);
cout<<"\n由栈底至栈顶的元素为:";
StackTraverse(S);
cout<<"\n栈的长度为:"<<StackLength(S)<<endl;
GetTop(S,e);
cout<<"\n栈顶元素为:"<<e<<endl;
}
相关分类