线性表的应用—栈操作.docVIP

  • 4
  • 0
  • 约1.8千字
  • 约 3页
  • 2018-03-11 发布于河南
  • 举报
线性表的应用—栈操作

#includestdio.h #includestdlib.h #define MAX 100 typedef struct//建立顺序栈 { int list[MAX]; int top,bot; }SeqStack; SeqStack S; int push(SeqStack *S,int x)//顺序栈进栈 { if(S-top==MAX) return 0; else { S-list[S-top++]=x; return 1; } } int pop(SeqStack *S)//顺序栈出栈 { if(S-top==0) return 0; else { S-top--; return 1; } } int stacktop(SeqStack *S)//对顺序栈取栈顶元素 { int x; if(S-top==0S-bot==0) return 0; else { x=S-list[--S-top]; return x; } } void Print(SeqStack *S)//输出顺序栈 { int b; do { b=S-list[S-top--]; if(b) printf(%d ,b); }while(b); putchar(\n); } typedef struct node//建立链栈 { int data;

文档评论(0)

1亿VIP精品文档

相关文档