华南农业大学数据结构上机答案实验 下载本文

typedef char stack; struct node {

stack a[size]; int top; };

int Isempty(struct node *s) {

return (s->top==-1?True:False); }

int Isfull(struct node *s) {

return (s->top+1==size?True:False); }

int Push(struct node *s,stack x) {

if(!Isfull(s)) { s->top++; s->a[s->top]=x;

return True; } else return False; }

int Pop(struct node *s, stack *x) { if(!Isempty(s)) {

*x=s->a[s->top]; s->top--;

return True; } else return False; }

int Gettop(struct node *s) { stack x; if(!Isempty(s)) {

x=s->a[s->top];

return x; } else return False; } //整形 栈 typedef int sta;

struct node1 { sta a[size]; int top; };

int Isempty1(struct node1 *s) {

return (s->top==-1?True:False); }

int Isfull1(struct node1 *s)

{

return (s->top+1==size?True:False); }

int Push1(struct node1 *s,sta x) {

if(!Isfull1(s)) { s->top++;

s->a[s->top]=x;

return True; } else return False; }

int Pop1(struct node1 *s, sta *x) {

if(!Isempty1(s)) {