stack.h 源码如下
#define STACK_INIT_SIZE 100
typedef int SElemType;
typedef struct {
SElemType Qstack[STACK_INIT_SIZE];
int top;
}baseStack, *SqStack;
//构造一个空栈
void InitStack(SqStack &S);
//把S置为空栈
void ClearStack(SqStack &S);
//判栈是否为空
bool StackEmpty(SqStack S);
int StackLength(SqStack S);
void Push(SqStack &S,SElemType e);
void Pop(SqStack &S,SElemType &e);
stack.cpp 源码如下
// stack.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stack.h"
#include <iostream>
using namespace std;
/************************************************************************/
/* C++中传递参数如果是指针的话,也是可以修改里面的值的,否则不能修改,
除非加上&引用符号 */
/************************************************************************/
//构造一个空栈
void InitStack(SqStack &S){
S->top = -1;
}
//把S置为空栈
void ClearStack(SqStack &S){
S->to