为了实现二叉树实现先序后序中序的程序
#define OK 1
#define ERROR 0
#define OVERFLOW -2
typedef int Status;
typedef struct BiTNode
{
char data;
struct BiTNode* lchild,*rchild;
}BiTNode,*BiTree;
typedef struct _N
{
BiTree tree;
struct _N* next;
}Nod,*Node;
typedef struct _Q
{
Node front;
Node rear;
}Queue;
Status QueueInit(Queue& Q)
{
Q.front=(Node)malloc(sizeof(Nod));
if(!Q.front)
return OVERFLOW;
Q.front->tree=NULL;
Q.front->next=NULL;
Q.rear=Q.front;
return OK;
}
Status QueueInsert(Queue& Q,BiTree tree)
{
Q.rear->next=(Node)malloc(sizeof(Nod));
if(!Q.rear->next)
return OVERFLOW;
Q.rear->next->tree=tree;
Q.rear=Q.rear->next;
return OK;
}