#include<iostream>//顺序栈
using namespace std;
#define maxsize 10000
typedef struct
{
int a;
}node;
typedef struct
{
node *base;
node *top;
int stacksize;
}Sqstack;
int Initstack(Sqstack& s)//初始化
{
s.base = new node[maxsize];
if (!s.base) return 0;
s.top = s.base;
s.stacksize = maxsize;
return 1;
}
int Emptystack(Sqstack s)//判空
{
if (s.top == s.base)
return 1;
else
return 0;
}
int Lengthstack(Sqstack s)//求长度
{
return s.top - s.base;
}
int Clearstack(Sqstack s)//清空
{
if (s.base) s.top = s.base;
return 1;
}
void Destroystack(Sqstack& s)//销毁
{
if (s.base)
{
delete s.base;
s.stacksize = 0;
s.base = s.top = NULL;
}
}
int Pushstack(Sqstack& s, node e)//入栈
{
if (s.top - s.base == s.stacksize)
return 0;
*s.top++ = e;
return 1;
}
int Popstack(Sqstack& s, node e)
{
if (s.top == s.base)return 0;
e = *--s.top;
return 1;
}
int main()
{
Sqstack s;
}
#include<iostream>//链栈
using namespace std;
typedef struct node
{
long long num;
char name;
int score;
};
typedef struct stack
{
node data;
stack* next;
}stack ,*Linkstack;
void Initstack(Linkstack& s)//初始化
{
s = NULL;
}
int Emptystack(Linkstack s)//判空
{
if (s == NULL)
return 1;
else
return 0;
}
void Pushstack(Linkstack& s, node e)//入栈
{
Linkstack p = new stack;
p->data = e;
p->next = s;
s = p;
}
int Popstack(Linkstack& s, node& e)//出栈
{
Linkstack p = new stack;
if (s == NULL) return 0;
e = s->data;
p = s;
s = s->next;
delete p;
return 1;
}
node Gettop(Linkstack s)//取栈顶元素
{
if (s != NULL)
return s->data;
}
int main()
{
Linkstack s;
}