栈的简单程序.docVIP

  • 6
  • 0
  • 约1.77千字
  • 约 4页
  • 2017-05-28 发布于河南
  • 举报
栈的简单程序

#includestdio.h #includemalloc.h #includestdlib.h #define STACK_INIT_SIZE 100 #define STACKINCREMENT 10 #define ERROR 0 #define OK 1; typedef int SElemType; typedef struct { SElemType *base; SElemType *top; int stacksize; }SqStack; // 初始化 int InitStack(SqStack S) { S.base=(SElemType *)malloc(STACK_INIT_SIZE*sizeof(SElemType)); if(!S.base) { printf(!\n); exit(ERROR); } S.top=S.base; S.stacksize=STACK_INIT_SIZE; printf(栈初始化完毕!\n); return OK; } // 入栈(插入元素) int Push(SqStack S,SElemType e) { if(S.top-S.base=S.stacksize) { S.base=(SElemType *)malloc(S.stacksize+S

文档评论(0)

1亿VIP精品文档

相关文档