T
tigerhacker
Unregistered / Unconfirmed
GUEST, unregistred user!
//1输入先序字符序列,建立二叉链表
Tree * CreateTreeH()
{
Tree *root;
char c;
if ((c=getchar())=='0') root=NULL;
else
{
root=(Tree *)malloc(sizeof(Tree));
root->data=c;
root->lchild=CreateTreeH();
root->rchild=CreateTreeH();
}
return root;
}
//这是先序的,可以成功
//2输入中序字符序列,建立二叉链表
Tree * CreateTreeM()
{
Tree *root;
char c;
if ((c=getchar())=='0') root=NULL;
else
{
root=(Tree *)malloc(sizeof(Tree));
root->lchild=CreateTreeM();
root->data=c;
root->rchild=CreateTreeM();
}
return root;
}
//这是中序的,不行!!
有人知道为什么么?
Tree * CreateTreeH()
{
Tree *root;
char c;
if ((c=getchar())=='0') root=NULL;
else
{
root=(Tree *)malloc(sizeof(Tree));
root->data=c;
root->lchild=CreateTreeH();
root->rchild=CreateTreeH();
}
return root;
}
//这是先序的,可以成功
//2输入中序字符序列,建立二叉链表
Tree * CreateTreeM()
{
Tree *root;
char c;
if ((c=getchar())=='0') root=NULL;
else
{
root=(Tree *)malloc(sizeof(Tree));
root->lchild=CreateTreeM();
root->data=c;
root->rchild=CreateTreeM();
}
return root;
}
//这是中序的,不行!!
有人知道为什么么?