递归中回退
bool search_update(Node * root,int x,int newx) {
if(root==NULL)return false;// 树空
if(root->d==x) {
root->d=newx;
return true;
}
bool f = search_update(root->l,x,newx);
if(f) return true;
return search_update(root->r,x,newx);
}
// 查找后序第一个结点
void post_first(Node * root,bool &flag) {
if(root==NULL||flag)return; // 标记校验
post_first(root->l,flag);
post_first(root->r,flag);
if(flag==false) { // 标记
printf("%d",root->d);
flag = true;
}
}