码迷,mamicode.com
首页 > 其他好文 > 详细

交换二叉树的左右子树

时间:2018-11-28 22:05:04      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:return   null   turn   lse   bin   roo   swa   temp   交换   


 1 root是根节点
 2 BiNode * temp, * root1;
 3 void swap(BiNode root1){
 4     if(root1 == NULL) return;
 5         else{
 6         temp = root1->lchild;
 7         root1->lchild = root1->rchild;
 8         root1->rchild = temp;
 9         swap(root1->lchild);
10         swap(root1->rchild);
11     }
12 }

 

 

 

交换二叉树的左右子树

标签:return   null   turn   lse   bin   roo   swa   temp   交换   

原文地址:https://www.cnblogs.com/moomcake/p/10034433.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!