剑指offer--对称二叉树
/* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { } }; */ class Solution { public: bool panduan(TreeNode* left, TreeNode* right) { if (left == NULL&&right == NULL) return true; if (left == NULL || right == NULL) return false; if (left->val == right->val) { return (panduan(left->left, right->right) && panduan(left->right, right->left)); } return false; } bool isSymmetrical(TreeNode* pRoot) { if (pRoot == NULL) return true; else { return panduan(pRoot->left, pRoot->right); } } };