#include <iostream>
using namespace std;
typedef int ElemType;
#define MaxSize 100
typedef struct
{
ElemType date[MaxSize];
int top;
}SqStack;
void SqstackInit(SqStack*&s)
{
s = (SqStack*)malloc(sizeof(SqStack));
s->top = -1;
}
bool pushSqstack(SqStack*&s, ElemType e)
{
if (s->top == MaxSize-1)
return false;
s->date[s->top + 1] = e;
s->top++;
return true;
}
bool pushOutStstack(SqStack*&s, ElemType &e)
{
if (s->top == -1)
return false;
s->date[s->top + 1] = e;
s->top--;
return true;
}
void destroyStstack(SqStack*&s)
{
free(s);
}
int main()
{
SqStack *s;
int i = 4,e;
SqstackInit(s);
pushSqstack(s,i);
pushOutStstack(s, e);
destroyStstack(s);
}
转载请注明原文地址:https://blackberry.8miu.com/read-32515.html