69,369
社区成员
发帖
与我相关
我的任务
分享
void insertBST(treeNode *T,int x){
treeNode *s;
if(T==NULL){
s=(treeNode* )malloc(sizeof(treeNode));
s->data=x;
s->left=NULL;
s->right=NULL;
T=s;
}
else{
if(x<T->data)
insertBST(T->left, x);
if(x>T->data)
insertBST(T->right,x);
}
}
void creatBST(treeNode *T,int n){
int i,x;
T=NULL;
for(i=0;i<n;i++){
scanf("%d",&x);
insertBST(T,x);
}
}