typedef struct node
{
char data;
struct node *lchild;
struct node *rchild;
}*Tree, Tnode;
static void CreateTree(Tree *T);
题目:二叉排序树
就一个函数:创建函数.
条件是:CreateTree()函数只能有一个参数,那就是"根".不能有同数据域相同类型的参数
创建成功者给3000金币
typedef struct node
{
char data;
struct node *lchild;
struct node *rchild;
}*Tree, Tnode;
static void CreateTree(Tree *T);
题目:二叉排序树
就一个函数:创建函数.
条件是:CreateTree()函数只能有一个参数,那就是"根".不能有同数据域相同类型的参数
创建成功者给3000金币
2006-05-17 23:51
2006-05-17 23:57
2006-05-17 23:58
2006-05-18 00:00
2006-05-18 00:20
前几天 刚做作业了的,还留的在。
void InsertBST(bitree *t,char key)
{
bitnode *f,*p=*t;
while(p){
if(p->data==key) return;
f=p;
p=(key<p->data)?p->lchild:p->rchild;
}/*endwhile*/
p=(bitnode *)malloc(sizeof(bitnode));
p->data=key;
p->lchild=NULL;
p->rchild=NULL;
if(*t==NULL) *t=p;
else
if(key<f->data) f->lchild=p;
else f->rchild=p;
}
BSTree CreateBST()
{
bitree t=NULL;
char key;
scanf("%1s",&key);
while(key=='#'){
InsertBST(&t,key);
scanf("%1s",&key);
}
return t;
}

2006-05-18 07:35
前几天 刚做作业了的,还留的在。
void InsertBST(bitree *t,char key)
{
bitnode *f,*p=*t;
while(p){
if(p->data==key) return;
f=p;
p=(key<p->data)?p->lchild:p->rchild;
}/*endwhile*/
p=(bitnode *)malloc(sizeof(bitnode));
p->data=key;
p->lchild=NULL;
p->rchild=NULL;
if(*t==NULL) *t=p;
else
if(key<f->data) f->lchild=p;
else f->rchild=p;
}
BSTree CreateBST()
{
bitree t=NULL;
char key;
scanf("%1s",&key);
while(key=='#'){
InsertBST(&t,key);
scanf("%1s",&key);
}
return t;
}
同学,你这东东能运行吗?

2006-05-18 07:59
typedef struct node
{
char data;
struct node *lchild;
struct node *rchild;
}*Tree, Tnode;
static void CreateTree(Tree *T);
题目:二叉排序树
就一个函数:创建函数.
条件是:CreateTree()函数只能有一个参数,那就是"根".不能有同数据域相同类型的参数
创建成功者给3000金币

2006-05-18 08:06
都说的什么啊!先看明白我的意思再说,我说的条件是:
条件是:CreateTree()函数只能有一个参数,那就是"根".不能有同数据域相同类型的参数
问题的关键是只能有"一个参数"

2006-05-18 08:50
我那需要返回值吗

2006-05-18 08:50