裁判测试程序样例:
#include <stdio.h>
#include <stdlib.h>
typedef char ElemType;
typedef struct BiTNode
{
ElemType data;
struct BiTNode *lchild,*rchild;
}BiTNode,*BiTree;
BiTree Create();/* 细节在此不表 */
int LeafCount ( BiTree T);
int main()
{
BiTree T = Create();
printf("%d\n", LeafCount(T));
return 0;
}
/* 你的代码将被嵌在这里 */
我的代码,显示错误原因为段错误
int LeafCount ( BiTree T)
{
int n;
if(T==NULL)
return 0;
if(T->lchild==NULL)
n=1;
if(T->lchild!=NULL)
LeafCount (T);
if(T->rchild!=NULL)
LeafCount (T);
return n;
}