#include<stdio.h>
#include<malloc.h>
typedef int keytype;
typedef struct node
{
    keytype data;
    struct node *left,*right;
}bitnode,*bitree;
//二叉排序树的查找
void searchbst (bitree bt,bitree *f,bitree *c,keytype key)
{ //在根结点bt所指的二叉排序树中,查找关键字值 等于key的数据
    //元素c指向找到的结点,f指向c的双亲结点。c,f的初值 都为空
    //若查找失败,则c为空
    while (bt!=NULL)
        if(bt->data==key)
        {
            *c=bt;break;}
        else if (key<bt->data)
        {
            *f=bt;bt=bt->left;}
        else
        {
            *f=bt;bt=bt->right;
        }
}
//二叉排序树的插入 
int insertbst(bitree *bt,keytype key)
{
    bitree f=NULL,c=NULL,s;
    searchbst(*bt,&f,&c,key);//bt为二级指针,存储根结点,地址指针
    if(c!=NULL)return 0;
     s=(bitree)malloc(sizeof(bitnode));
     s->data=key;
     s->left=s->right=NULL;
     if(f==NULL)*bt=s;//插入结点为根结点
     else if(key<f->data)
         f->left=s;//插入新结点
     else f->right=s;
     return 1;
}
//二叉排序树的创建
void creatbst(bitree *bt)
{
    keytype key;
    *bt =NULL;//根结点的初值为空
    scanf("%",&key);
    while(key!=-1)
    {
        insertbst(bt,key);
        scanf("%d",&key);
    }
}
    void main()
    {
        bitree *bt;
        bt=NULL;
        creatbst(bt);
    }



											
	    

	