栈的应用--进制的转换表达式括号匹配.docVIP

  • 4
  • 0
  • 约4.25千字
  • 约 5页
  • 2016-08-29 发布于重庆
  • 举报

栈的应用--进制的转换表达式括号匹配.doc

栈的应用--进制的转换表达式括号匹配

#includestdio.h #includestdlib.h #includestring.h #define STACK_INIT_SIZE 100 /*存储空间初始分配量*/ #define STACKINCREMENT 10 /*存储空间分配增量*/ typedef int SElemType; typedef struct { SElemType *base; /*在栈构造之前和销毁之后,base的值为NULL*/ SElemType *top; /*栈顶指针*/ int stacksize; /*当前已分配的存储空间,以元素为单位*/ }SqStack; int InitStack(SqStack S) /*初始化空栈*/ { S.base=(SElemType *)malloc(STACK_INIT_SIZE * sizeof(SElemType)); if(!S.base) exit(0); /*存储分配失败*/ S.top=S.base; S.stacksize=STACK_INIT_SIZE; return 1; } int Push(SqStack S,SElemType e) /*入栈*/ { if(S.top-S.

文档评论(0)

1亿VIP精品文档

相关文档