大佬们好 ,请分析下哪里出了问题 谢谢
#include<stdio.h>#include<malloc.h>
struct BTNode
{
char data;
struct BTNode * pLchild;
struct BTNode * pRchild;
};
//函数声明
struct BTNode * CreateBTree(void);
PreTraverseBTree(struct BTNode * pT);//先序遍历
InTraverseBTree(struct BTNode * pT);//中序遍历
PostTraverseBTree(struct BTNode * pT); //后序遍历
int main(void)
{
struct BTNode * pT=CreateBTree();
PreTraverseBTree(pT);//先序遍历
InTraverseBTree(pT);//中序遍历
PostTraverseBTree(pT); //后序遍历
return 0;
}
//先序遍历
void PreTraverseBTree(struct BTNode * pT)
{
//pT->pLchild可以代表整个左子树
if(NULL!=pT)
{
printf("%c\n",pT->data);
if(NULL!=pT->pLchild)
{
PreTraverseBTree(pT->pLchild);
}
if(NULL!=pT->pRchild)
{
PreTraverseBTree(pT->pRchild);
}
}
}
//中序遍历
void InTraverseBTree(struct BTNode * pT)
{
if(NULL!=pT)
{
if(NULL!=pT->pLchild)
{
InTraverseBTree(pT->pLchild);
}
printf("%c\n",pT->data);
if(NULL!=pT->pRchild)
{
InTraverseBTree(pT->pRchild);
}
}
}
//后序遍历
void PostTraverseBTree(struct BTNode * pT)
{
if(NULL!=pT)
{
if(NULL!=pT->pLchild)
{
PostTraverseBTree(pT->pLchild);
}
if(NULL!=pT->pRchild)
{
PostTraverseBTree(pT->pRchild);
}
printf("%c\n",pT->data);
}
}
struct BTNode * CreateBTree(void)
{ //创建树
struct BTNode * pA=(struct BTNode*)malloc(sizeof(struct BTNode));
struct BTNode * pB=(struct BTNode*)malloc(sizeof(struct BTNode));
struct BTNode * pC=(struct BTNode*)malloc(sizeof(struct BTNode));
struct BTNode * pD=(struct BTNode*)malloc(sizeof(struct BTNode));
struct BTNode * pE=(struct BTNode*)malloc(sizeof(struct BTNode));
pA->data='A';
pB->data='B';
pC->data='C';
pD->data='D';
pE->data='E';
pA->pLchild = pB;
pA->pRchild = pC;
pB->pLchild = pB->pRchild = NULL;
pC->pLchild = pD;
pC->pRchild = NULL;
pD->pLchild = NULL;
pD->pRchild = pE;
pE->pLchild = pE->pRchild = NULL;
return pA;
}
//错误提示为 31 6 C:\Users\WP-S10\Desktop\树和图\创建树.c [Error] conflicting types for 'PreTraverseBTree'