堆栈,队列的操作上级实验.docVIP

  • 13
  • 0
  • 约5.09千字
  • 约 9页
  • 2016-06-26 发布于重庆
  • 举报
堆栈,队列的操作上级实验

实验二 堆栈和队列的基本操作一、 目的初始化栈、判栈为空、出栈、入栈等运算。二、要求1、认真阅读和掌握本实验的算法。2、上机将本算法实现。3、保存和打印出程序的运行结果,并结合程序进行分析。三、内容(顺序结构、链式结构)队列操作:栈、判断栈空、出栈入栈等运算。#includeString typedef char ElemType; #define StackSize 100 /*顺序栈的初始分配空间*/ typedef struct { ElemType data[StackSize]; /*保存栈中元素*/ int top; /*栈顶指针*/ } SqStack; void InitStack(SqStack st) { st.top=-1; } int Push(SqStack st,ElemType x) /*进栈运算*/ { if (st.top==StackSize-1) /*栈满*/ return 0; else /*栈不满*/ { st.top++; st.data[st.top]=x; return 1; } } int Pop(SqStack st,ElemType x) /*出栈运算*/ { if (st.top==-1) /*栈空*/ return

文档评论(0)

1亿VIP精品文档

相关文档