C++/代码:
class Solution { public: void Mirror(TreeNode *pRoot) { if (!pRoot) return; //为空则结束,因为是void函数,则无返回值,结束则为空 swap(pRoot->left,pRoot->right); Mirror(pRoot->left); Mirror(pRoot->right); } };
C++/代码:
class Solution { public: void Mirror(TreeNode *pRoot) { if (!pRoot) return; //为空则结束,因为是void函数,则无返回值,结束则为空 swap(pRoot->left,pRoot->right); Mirror(pRoot->left); Mirror(pRoot->right); } };