请大神帮我解决这几个问题
//设计树结构的相关函数库,以便在程序设计中调用。#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
char data;
struct Node * Lchild;
struct Node * Rchild;
}BiTNode,*BiTree;//二叉树节点,二叉链表
typedef struct QueueNode{
BiTree data;
struct QueueNode *next;
}LinkQueueNode;//队列中的每个节点
typedef struct
{
LinkQueueNode *front;
LinkQueueNode *rear;
}LinkQueue;//队列
/* 队列的初始化 */
void InitQueue(LinkQueue *Q)
{
Q->front = (LinkQueueNode *)malloc(sizeof(LinkQueueNode));
if(Q->front != NULL){
Q->rear = Q->front;
Q->front->next = NULL;
}else printf("分配空间失败!\n");
}
/* 入队 */
void EnterQueue(LinkQueue *Q,BiTree x)
{
LinkQueueNode *NewNode;
NewNode = (LinkQueueNode *)malloc(sizeof(LinkQueueNode));
if(NewNode != NULL){
NewNode->data = x;
NewNode->next = NULL;
Q->rear->next = NewNode;
Q->rear = NewNode;
}
}
/* 队列判空*/
int QueueIsEmpty(LinkQueue *Q)
{
if(Q->front == Q->rear)
return 1;
else return 0;
}
/* 出队*/
void DeleteQueue(LinkQueue *Q,BiTree *x)
{
LinkQueueNode *p;
if(Q->front == Q->rear)
return ;
p= Q->front->next;
Q->front->next = p->next;
if(Q->rear == p)
Q->rear = Q->front;
*x = p->data;
free(p);
}
/* 利用扩展先序遍历序列
创建二叉链表*/
void CreateBiTree(BiTree *bt)
{
char ch;
ch = getchar();
if(ch == '.') *bt = NULL;
else
{
*bt = (BiTree)malloc (sizeof(BiTNode));
(*bt)->data = ch;
CreateBiTree(&((*bt)->Lchild));
CreateBiTree(&((*bt)->Rchild));
}
}
/*先序递归遍历二叉树*/
void PreOrder(BiTree root)
{
if(root != NULL){
printf("%c ",root->data);
PreOrder(root->Lchild);
PreOrder(root->Rchild);
}
}
/*后序递归遍历二叉树 */
void PostOrder(BiTree root)
{
if(root != NULL){
PostOrder(root -> Lchild);
PostOrder(root -> Rchild);
printf("%c ",root->data);
}
}
void InOrder(BiTree root)
{
if(root != NULL){
InOrder(root->Lchild);
printf("%c ",root->data);
InOrder(root->Rchild);
}
}
/* 层序遍历
对给定的二叉树进行层序遍历 */
void LayerOrder(BiTree root)
{
BiTree *x;
//这里要记得申请空间
x = (BiTree *)malloc(sizeof(BiTree));
if(x == NULL){
printf("内存分配失败!\n");
}
LinkQueue *Q;
Q = (LinkQueue *)malloc(sizeof(LinkQueue));
InitQueue(Q);
EnterQueue(Q,root);
while(!QueueIsEmpty(Q)){
DeleteQueue(Q,x);
printf("%c ",(*x)->data);
if((*x)->Lchild)EnterQueue(Q,(*x)->Lchild);
if((*x)->Rchild)EnterQueue(Q,(*x)->Rchild);
}
}
void countleaf(BiTree root,int&n)
{ if (root)
{
countleaf(root->Lchild,n);
if(!root->Lchild && !root->Rchild) n++;
countleaf(root->Rchild,n);
}
}
void depth(BiTree root,int &dep)
{ int dep1,dep2;
if(!root) dep=0;
else
{depth(root->Lchild,dep1);
depth(root->Rchild,dep2);
dep=dep1>dep2?dep1+1:dep2+1;
}
}
int main(int argc , char **argv)
{
int n=0,dep;
BiTree root;
CreateBiTree(&root);
printf("先序递归遍历:\n");
PreOrder(root);
printf("\n");
printf("中序递归遍历:\n");
InOrder(root);
printf("\n");
printf("后序递归遍历:\n");
PostOrder(root);
printf("\n");
printf("层序遍历:\n");
LayerOrder(root);
printf("\n");
depth(root,dep);
printf("深度dep=%d\n",dep);
countleaf(root,n);
printf("叶子结点数n=%d\n",n);
printf("\n");
return 0;
}
错误提示:
(109) :error C2275: 'LinkQueue' : illegal use of this type as an expression
(109) : error C2065: 'Q' : undeclared identifier
(120) :error C2143: syntax error : missing ')' before '&'
(120) :error C2143: syntax error : missing '{' before '&'
(120) : error C2059: syntax error : '&'
(120) : error C2059: syntax error : ')'