操作给定的二叉树,将其变换为源二叉树的镜像。
题目介绍
操作给定的二叉树,将其变换为源二叉树的镜像。
输入描述
源代码
/*
struct TreeNode {int val;struct TreeNode *left;struct TreeNode *right;TreeNode(int x) :val(x), left(NULL), right(NULL) {}
};*/
class Solution {
public:void Mirror(TreeNode *pRoot) {TreeNode *node;if(pRoot==NULL){return ;}else if(pRoot->left==NULL&&pRoot->right==NULL){return ;}node=pRoot->right;pRoot->right=pRoot->left;pRoot->left=node;Mirror(pRoot->left);Mirror(pRoot->right);}
};