问题:二叉树镜像
输入二叉树,求二叉树的镜像。
void reversetree(TreeNode* tree)
{
if (tree == NULL)
return;
TreeNode* treeleft = tree->getleft();
TreeNode* treeright = tree->getright();
if (treeleft != NULL)
{
tree->setright(treeleft);
reversetree(treeleft);
}
if (treeright != NULL)
{
tree->setleft(treeright);
reversetree(treeright);
}
}