最近开始复习严蔚敏的《数据结构》,以下是顺序栈基本功能的实现,与书中完全对应。
/*
* 功能:顺序栈的实现
* 作者:风清扬
* 日期:2014-12-30
*/
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define OVERFLOW -2
#define STACK_INIT_SIZE 10
#define STACK_INCREMENT 2
typedef int Status;
typedef int SElemType;
//==============================================================================
/*------------------------------定义顺序栈数据类型-----------------------------*/
typedef struct
{
SElemType * bottom;//栈底
SElemType * top;//栈顶
int stackSize;//栈容量
} SqStack;
void Init