实验四 栈的设计及应用.docVIP

  • 9
  • 0
  • 约1.9千字
  • 约 4页
  • 2018-05-27 发布于河南
  • 举报
实验四 栈的设计及应用

实验四 栈的设计及应用 一.实验目的 1.掌握栈的逻辑结构。 2.掌握顺序栈、链栈的设计过程。 3.使用设计的栈实现进制转换。 二、实验内容 1.设计顺序栈:设计头文件SqStack.h,其内容如下: #define MaxLen 20 #include stdlib.h typedef struct { Selemtype data[MaxLen]; int top; }SqStack; //初始化栈 void InitStack(SqStack S) { //栈中数据元素个数为0 S.top=0; } //判栈空 int StackEmpty(SqStack S) { //栈中元素个数为0,则为空 if(S.top==0) return 1; else return 0; } //判栈满 int StackFull(SqStack S) { //栈中元素个数为MaxLen if(S.topMaxLen) return 1; else return 0; } void push(SqStack S,Selemtype e) { if(StackFull(S)) { coutStack is full,the program break!; exit(-1); } //将元素e插入到栈顶 S.data[S.t

文档评论(0)

1亿VIP精品文档

相关文档