程序纠错——数据结构二叉树求结点最大值(C语言)
#include<stdio.h>#include<stdlib.h>
typedef int elemtype;
typedef struct node
{ elemtype data;
struct node *lchild,*rchild;
}BTNode,*BTree;
BTree CreateBTree(BTree &T)
{
int number;
if(number!=0)
{scanf("%d",&number);
T=(BTNode*)malloc(sizeof(BTNode));
T->data=number;
CreateBTree(T->lchild);
CreateBTree(T->rchild);
}
}
int MAX(BTree BT)
{int m;
if(BT!=NULL)
m=BT->data;
if(BT->data>m)
m=BT->data;
MAX(BT->lchild);
MAX(BT->rchild);
return m;
}
void main()
{BTree T;
int n;
CreateBTree(T);
n=MAX(T);
printf("%d",n);
}