visual c++数据结构高手请进!!!!!!!!!!!!!!

来源:百度知道 编辑:UC知道 时间:2024/06/01 12:01:22
建立二叉树,层序、中序、遍历。(请用递归的方法)
任务:要求能过输入二叉树的各个结点,并能够用不同的方法遍历的遍历序列!
要求:分别建立二叉树存储结构的输入函数,输出序列,遍历序列的函数,输出中序遍历序列的函数。

#include<stdio.h>
#include<stdlib.h>

#define OK 1;
#define FALSE 0;
#define ERROR 0;
#define TRUE 1;

typedef int Status;
typedef char TElemType;
typedef int Status;

typedef struct BiTNode
{
TElemType data;
struct BiTNode *lchild,*rchild;
}BiTNode,*BiTree;

typedef BiTree ElemType;

typedef struct LNode
{
ElemType data;
struct LNode *next;
}LNode,*LNodeptr;

typedef struct LStack
{
LNodeptr top;
LNodeptr base;
}LStack;

typedef BiTree ElemType;
Status InitStack(LStack &s)
{
s.base=s.top=(LNodeptr)malloc(sizeof(LNode));
if(!s.base)
exit (-1);
s.base->next=NULL;
return OK;
}

Status StackEmpty(LStack s)
{
if(s.top==s.base)
{
return 1;
}
else
{
return 0;
}
}

Status Push(LStack &s,E