求二叉树的镜像:
void MirrorBiTree(BiTree* pNode)
{
if(pNode == NULL||pNode->leftChild ==NULL || pNode->rightChild ==NULL)
return ;
ListNode* temp;
temp = pNode->leftChild;
pNode->leftChild = pNode->rightChild;
pNode->rightChild = temp;
if( pNode->rightChild)
{
MirrorBiTree( pNode->rightChild);
}
if(pNode->leftChild)
{
Mirror(pNode->leftChild);
}
}
}
时间: 2024-10-08 15:49:37