// 栈是仅限定在表尾进行插入和删除的操作的表;下面以栈的链式储存结构为例。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct StackNode{
int data;
struct stacknode *next;
}stacknode,*linkstackptr;
typedef struct LinkStack{
linkstackptr top;
int cnt;
}linkstack;
int Initstack(linkstack *s)
{
s->top=(linkstackptr)malloc(sizeof(stacknode));
if(!(s->top))
return -1;
s->top=NULL;
s->cnt=0;
return 1;
}
int push(linkstack *s,int val)
{
linkstackptr p=(linkstackptr)malloc(sizeof(stacknode));
if(!p)
return -1;
p->data=val;
p->next=s->top;
s->top=p;
s->cnt++;
return 1;
}
int length(linkstack *s)
{
if(s->cnt