标签:void subject font size strong style str mil 二叉树
二叉树的镜像定义:源二叉树
8
/ 6 10
/ \ / 5 7 9 11
镜像二叉树
8
/ 10 6
/ \ / 11 9 7 5
1 /* 2 struct TreeNode { 3 int val; 4 struct TreeNode *left; 5 struct TreeNode *right; 6 TreeNode(int x) : 7 val(x), left(NULL), right(NULL) { 8 } 9 };*/ 10 class Solution { 11 public: 12 void Mirror(TreeNode *pRoot); 13 }; 14 15 void Solution::Mirror(TreeNode *pRoot) 16 { 17 if(pRoot != NULL) 18 { 19 TreeNode *temp; 20 temp = pRoot->left; 21 pRoot->left = pRoot->right; 22 pRoot->right = temp; 23 Mirror(pRoot->left); 24 Mirror(pRoot->right); 25 } 26 27 }
标签:void subject font size strong style str mil 二叉树
原文地址:http://www.cnblogs.com/htzhang0908/p/6648958.html