(1)熟悉栈的特点(先进后出)及栈的基本操作,如入栈、出栈等,掌握栈 的基本操作在栈的顺序存储结构和链式存储结构上的实现; (2)熟悉队列的特点(先进先出)及队列的基本操作,如入队、出队等,掌 握队列的基本操作在队列的顺序存储结构和链式存储结构上的实现。
【实验步骤】 (1)建立顺序栈SeqStack,存放测试数据;建立队列SeqQueue存放出栈数据; (2)建立InitStack、StackEmpty、StackFull、Pop、Push、GetTop函数用作顺序栈的基本操作; (3)建立InitQueue、QEmpty、Qfull、InQueue、OutQueue、ReadFront函数用作队列的基本操作; (4)建立主函数依次按序对子函数进行操作:InitStack初...
if(StackEmpty(S)){printf("当前栈为空,不能执行此操作\n”);exit(0);} e=*—S.top; return e; } void main() { int i=0,e; int *p; SqStack S; S=Initstack(); printf("\n1.元素进栈\n2.元素出栈\n3.取栈顶元素\n4. 求栈的长度\n5.判栈空\n6.退出\n“); ...
【实验内容】 1.链栈的基本操作(链栈的初始化、进栈、出栈以及取栈顶的值) #include "stdio.h" #include "malloc.h" #include "stdlib.h" typedef int Elemtype; typedef struct stacknode { Elemtype data; stacknode * next; }StackNode; typedef struct { ...