剑指offer-19 二叉树的镜像

来源:互联网 发布:折线统计图数据举例 编辑:程序博客网 时间:2024/06/16 10:48
#include <iostream>using namespace std;struct BinaryTreeNode{    int value;    BinaryTreeNode* left;    BinaryTreeNode* right;    BinaryTreeNode(int val) : value(val),left(NULL),right(NULL){}};void MirrorOfBinaryTree(BinaryTreeNode* root){    if(root==nullptr)        return ;    if(root->left==nullptr || root->right==nullptr)        return ;    BinaryTreeNode *ptemp = root->left;    root->left = root->right;    root->right = ptemp;    if(root->left)        MirrorOfBinaryTree(root->left);    if(root->right)        MirrorOfBinaryTree(root->right);}int main(){    return 0;}

0 0
原创粉丝点击