2.反转二叉树左右子树
BiTree invertTree(BiTree pRoot)
{
if (pRoot == NULL) {
return NULL;
}
pRoot->lchild = invertTree(pRoot->lchild);
pRoot->rchild = invertTree(pRoot->rchild);
BiTree pTmep = pRoot->lchild;
pRoot->lchild = pRoot->rchild;
pRoot->rchild = pTmep;
return pRoot;
}
调用
BiTree newTree = invertTree(rootTree);
PreOrderTraverse(newTree); printf("\n");
log:70,60,50,40,30,20,10,
原文:http://www.cnblogs.com/menchao/p/4834852.html