//遍历
void print(int p){
if(!p) return;
print(left[p]);
printf("%d\n",a[p]);
print(right[p]);
}//查找
int find(int x,int p){
if(!p) return ;
if(x==a[p]) return p;
else if(x<a[p]) return find(x,lef[p]);
else return find(x,right[p]);
}//最值
int findmin(int p){
if(p) while(left[p]) p=left[p];
return p;
}
void insert(int x,int &p){
if(!p) p=newnode(x);//新建以x为值的节点
else if(x<a[p]) insert(x,left[p]);
else if(x>a[p]) insert(x,right[p]);
}
int deletemin(int &x){
if(!left[x]){
int k=a[x];
x=right[x];
return k;
}
else return deletemin(left[x]);
}
void delete(int &x,int p){
if(a[x]==p){
if(left[x]&&right[x])//有两个非空节点
a[x]=deletemin(right[x]);
else
x=left[x]+right[x];
return;
}
if(a[x]>p) delete(left[x],p);
else delete(right[x],p);
}