zoukankan      html  css  js  c++  java
  • 二叉树的镜像

    struct Tree()
    {	
    	int val;
    	Tree *left, *right;
    	Tree(int a): val(a), left(NULL), right(NULL){}
    }
    bool mirrorTree(Tree *root){
    	
    	if(root == NULL || (root->left== NULL && root->right == NULL)) return NULL ;
    	 
    	Tree *tp = root->left;
    	root->left = root->right;
    	root->right = tp;
    	 
    	if(root->left)
    			mirrorTree(root->left);
    	
    	if(root->right)
    			mirrorTree(root->right);
    }
    

      

  • 相关阅读:
    代理模式
    适配器模式
    原型模式
    创建者模式
    装饰模式
    web总结
    4.14
    4.14
    POJ2385
    POJ2229
  • 原文地址:https://www.cnblogs.com/graph/p/3321769.html
Copyright © 2011-2022 走看看