二叉树的镜像
void MirrorRecursively(BinaryTreeNode* pRoot)
{
if (pRoot == nullptr || (pRoot->m_pLeft == nullptr && pRoot->m_pRight == nullptr))
return;
BinaryTreeNode* pTemp = pRoot->m_pLeft;
pRoot->m_pLeft = pRoot->m_pRight;
pRoot->m_pRight = pTemp;
if (pRoot->m_pLeft)
MirrorRecursively(pRoot->m_pLeft);
if (pRoot->m_pRight)
MirrorRecursively(pRoot->m_pRight);
}
浙公网安备 33010602011771号