来自《剑指offer》 二叉树镜像

来源:互联网 发布:知金教育的含金量如何 编辑:程序博客网 时间:2024/05/24 05:08
//二叉树镜像
#include<iostream>using namespace std;struct BinaryTreeNode{int m_nValue;BinaryTreeNode *m_pLeft;BinaryTreeNode *m_pRight;};void MirrorRecursively(BinaryTreeNode *pNode){if(pNode==NULL)return;if(pNode->m_pLeft==NULL&&pNode->m_pRight==NULL)return;BinaryTreeNode *pTemp=pNode->m_pLeft;pNode->m_pLeft =pNode->m_pRight;pNode->m_pRight =pTemp;if(pNode->m_pLeft)MirrorRecursively(pNode->m_pLeft);if(pNode->m_pRight )MirrorRecursively(pNode->m_pRight);}

0 0
原创粉丝点击