public class Solution {code
public void Mirror(TreeNode root) { //節點爲空返回 if(root==null) return; TreeNode temp; //交換左右節點 temp=root.left; root.left=root.right; root.right=temp; //若是左子樹還有子節點,在來一次 Mirror(root.left); //若是右子樹還有子節點,在來一次 Mirror(root.right); }
}io