// Tree.cpp : Defines the entry point for the console application.
//---二叉链表存储表示---
#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include <malloc.h>
using namespace std;
#define STACK_INI_SIZE 100
#define STACKINCREMENT 10
typedef char TElemType;
typedef int Status;
typedef char SElemType;//数据类型
typedef struct BiTreeNode{
SElemType data;
struct BiTreeNode *lchild, *rchild;
}BiTreeNode,*BiTree;
typedef struct{
SElemType *base;
SElemType *top;
int stacksize; //当前已分配空间
}SqStack;
bool InitStack(SqStack &s){
s.base = (SElemType *)malloc(sizeof(SElemType));
if (!s.base)
exit(OVERFLOW);
s.top = s.base;
s.stacksize = STACK_INI_SIZE;
return true;
}
bool getTop(SqStack &s, SElemType e){
if (s.top == s.base)//若栈不空,则用e 返回S的栈顶元素
return false;
e = *(s.top - 1);
return true;
}
bool Push(