栈与队列应用

理解并用顺序栈操作运行下列程序:

#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;

}


说忆
浏览 1141回答 0
0回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

数据结构