数据结构实验4_栈的操作.docxVIP

  • 30
  • 0
  • 约1.45千字
  • 约 3页
  • 2019-12-31 发布于陕西
  • 举报
《数据结构》实验报告 实验序号:4           实验项目名称:栈的操作 学  号 姓  名 专业、班 实验地点 指导教师 实验时间 一、实验目的及要求 1. 熟悉栈的基本概念; 2. 掌握栈的顺序存储结构; 3.掌握栈的应用。 二、实验设备(环境)及要求 微型计算机; windows 操作系统; Microsoft Visual Studio 6.0集成开发环境。 三、实验内容与步骤 1.栈的顺序表表示和实现的如下: #include iostream #define MaxSize 100 using namespace std; typedef int ElemType; typedef struct { ElemType data[MaxSize]; int top; }SqStack; void InitStack(SqStack *st) //初始化栈 { st-top=-1; } int StackEmpty(SqStack *st) //判断栈为空 { return (st-top==-1); } void Push(SqStack *st,ElemType x) //元素进栈 { if(st-top==MaxSize-1) { printf(栈上溢出!\n); } else { st-top++;

文档评论(0)

1亿VIP精品文档

相关文档