1 / 8
文档名称:

数据结构 栈和队列的基本操作实现及其应用.doc

格式:doc   页数:8页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

数据结构 栈和队列的基本操作实现及其应用.doc

上传人:yzhqw888 2016/4/21 文件大小:0 KB

下载得到文件列表

数据结构 栈和队列的基本操作实现及其应用.doc

文档介绍

文档介绍:实验二栈和队列的基本操作实现及其应用一、实验目的 1、熟练掌握栈和队列的基本操作在两种存储结构上的实现。 2、会用栈和队列解决简单的实际问题。二、实验内容(可任选或全做) 题目一、试写一个算法,判断依次读入的一个以@为结束符的字符序列, 是否为回文。所谓“回文“是指正向读和反向读都一样的一字符串,如“321123 ”或“ableelba ”。相关常量及结构定义: #define STACK_INIT_SIZE 100 #define STACKINCREMENT 10 #define OK1#define ERROR 0typedef int SElemType; //栈类型定义 typedef struct SqStack {SElemType *base; SElemType *top; int stacksize; }SqStack; 设计相关函数声明: 判断函数: int IsReverse() 栈: int InitStack(SqStack &S) int Push(SqStack &S, SElemType e) int Pop(SqStack &S,SElemType &e) int StackEmpty(s) 题目二、编程模拟队列的管理,主要包括: 出队列、入队、统计队列的长度、查找队列某个元素 e、及输出队列中元素。[ 实现提示] :参考教材循环队列的有关算法,其中后两个算法参考顺序表的实现。题目三、 Rails Description There isa famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was possible to establish only a surface track. Moreover, it turned out that the station could be only a dead-end one (see picture) and due to lack of available space it could have only one track. The local tradition is that every train arriving from the direction A continues in the direction B with coaches anized in some way. Assume that the train arriving from the direction A has N <= 1000 coaches numbered in increasing order 1,2,..., N. The chief for train anizations must know whether it is possible to marshal coaches continuing in the direction B so that their order wi