//***************************************************************//
//栈的表示和实现 (爱X的味道)//
//*************************************************************//
/*
typedef struct z_stack_node
{
StackElementType elem[stack_size];
int top;
}z_stack;
void InitStack(z_stack *stack)
{
stack->top=-1;
}
int Push(z_stack *stack, StackElementType x)
{
if(stack->top ==stack_size)
return FALSE;
stack->top++;
stack->elem[stack->top]=x;
return TRUE;
}
int Pop(z_stack *stack, StackElementType *x)
{
if(stack->top == -1)
return FALSE;
*x=stack->elem[stack->top];
stack->top--;
return TRUE;
}
int GetTop(z_stack *stack, StackElementType *x)
{
if(s->top == -1)
return FALSE;
*x =stack->elem[stack->top];
return TRUE;
}
*/
//**************************************************************//
************双端顺序栈 (爱X的味道)*******************
//*************************************************************//
/*
typedef struct z_stack
{
StackElementType stack[M];
int top[2];
}z_dstack;
void Init(z_dstack *dstack)
{
dstack->top[0]=-1;
dstack->top[1]=M;
}
int Push(z_dstack *sdtack,StackElementType x,int i)
{
if(dstack->top[0]+1==dstack->top[1])
return FALSE;
switch(i)
{
case 0:
dstack->top[0]++;
dstack->stack[dstack->top[0]]=x;
break;
case 1:
dstack->top[1]--;
dstack->stack[dstack->top[1]]=x;
break;
default:
return FALSE;
}
return TRUE;
}
int Pop(z_dstack *dstack,StackElementType x,int i)
{
switch(i)
{
case 0:
if(dstack->top[0]==-1)
return FALSE;
x=dstack->stack[dstack->top[0]];
dstack->top[0]--;
break;
case 1:
if(dstack->top[1]==M)
return FALSE;
x=dstack->stcak[dstack->top[1]];
dstack->top[1]++;
break;
default:
return FALSE;
}
return TRUE;
}
*/
//*****************************************************************//
*****************链栈的操作(爱X的味道)********************///
//*****************************************************************//
/*
typedef struct z_node
{
StackElementType data;
struct z_node *next;
}z_link_stack;
//进栈操作 就像头插法
int Push(z_link_stack *top,StackElementType x)
{
z_link_stack *tmp;
tmp=(z_link_stack *)malloc(sizeof(z_node));
if(tmp==NULL)
return FALSE;
tmp->data=x;
tmp->next=top->next;
top->next=tmp;
return TRUE;
}
int Pop(z_link_stack *top,StackElementType *x)
{
z_link_stack *tmp;
tmp=top->next;
if(tmp==NULL)
return FALSE;
top->next=tmp->next;
*x =tmp->data;
free(tmp);
return TRUE;
}
*/
//****************************************************************//
********************多栈操作(爱X的味道)***********************//
//****************************************************************//
/*
typedef struct z_node
{
StackElementType data;
struct z_node *next;
}z_link_stack,*link_stack;
link_stack top[M];
//第i号栈的进栈操作
int Push(z_link_stack *top[M],int i,StackElementType x)
{
z_link_stack *tmp;
tmp=(z_link_stack *)malloc(sizeof(z_link_stack));
if(tmp == NULL)
return FALSE;
tmp->data=x;
tmp-next=top[i]->next;
top[i]->next=tmp;
return TRUE;
}
int Pop(z_link_stack *top[M],int i,StackElementType x)
{
z_link_stack *tmp;
tmp=top[i]->next;
if(tmp == NULL)
return FALSE;
x=tmp->data;
top[i]->next=tmp->next;
free(tmp);
return TRUE;
}
*/