第三章 栈队列.pptVIP

  • 8
  • 0
  • 约6.25千字
  • 约 28页
  • 2016-12-13 发布于河南
  • 举报
第三章 栈和队列 入栈 Push (s, x) 前提:栈不满 bool Push ( SqStack s, DataType x ) { if ( s.top == StackSize ) return false; // 栈满 s.elem[top] = x; top++;// 或者s.elem[top++] = x; // 代替这两行 return true; } 出栈 Pop (s, x) 前提:栈非空 bool Pop ( SqStack s, DataType x ) { if ( s.top==0 ) return false; top--;x = s.elem[top]; // 可用x=s.elem[--top]; // 代替这两行 return true; } 栈顶元素 前提:栈非空 s.elem[top-1] 即是。 3.3 栈与递归过程 类似过程:栈和过程调用 考虑下述三个过程: procedure A1(…);  procedure A2(…);  procedure A3(…);    beginbeginbegin┇┇┇r:A2(…);t:A3(…);end;r1:┇t1: ┇    end;end;   这三个过程这间存在下述调用关系:过程A1在其过程体的某一处调用过程A2,A2以

文档评论(0)

1亿VIP精品文档

相关文档