二叉樹中查找值爲x的結點,打印x結點的全部祖先
int PrintAncestors(PBinTree root, int x)
{
if (!root) return 0;
if (root->data == x) return 1;
//如果子樹中可以找到匹配值 那麼此節點肯定是祖先結點
if (PrintAncestors(root->lchild, x) || PrintAncestors(root->rchild, x))
{
printf("%c ", root->data);
return 1;
}
return 0;
}//打印祖先