static struct TreeLinkNode *pre = NULL;
static struct TreeLinkNode *ret = NULL;
//中序遍历,结果存入ret
void Inorder(struct TreeLinkNode *root, int val)
{
if (!root || ret)
return;
Inorder(root->left, val);
if (pre && pre->val == val)
ret = root;
pre = root;
Inorder(root->right, val);
}
struct TreeLinkNode *GetNext(struct TreeLinkNode *pNode)
{
struct TreeLinkNode *root;
root = pNode;
while (root->next)
root = root->next;
Inorder(root, pNode->val);
return ret;
}