二叉树的镜像

题目:请完成一个函数,输入一个二叉树,该函数输出它的镜像

 1 #include<iostream>
 2 using namespace std;
 3 struct BinaryTreeNode{
 4     int value;
 5     BinaryTreeNode* p_Left;
 6     BianryTreeNode* P_Right;
 7 };
 8 void ReBinaryTreeNode(BinaryTreeNode* root)
 9 {
10     if(root==nullptr||(root->p_Left==nullptr&&root->p_Right))
11         return;
12     BinaryTreeNode* temp=root->p_Left;
13     root->p_Left=root->p_Right;
14     root->p_Right=temp;
15     if(root->p_Left)
16         ReBinaryTreeNode(root->p_Left);
17     if(root->p_Right)
18         ReBinaryTreeNode(root->p_right);
19 }

 

posted @ 2016-04-26 22:39  General_up  阅读(191)  评论(0编辑  收藏  举报