题目:https://leetcode.com/problems/same-tree/description/
代码:
class Solution {
public:
bool isSameTree(TreeNode* p, TreeNode* q) {
if(p==NULL&&q==NULL) return true;
else if(p==NULL&&q!=NULL||p!=NULL&&q==NULL) return false;
else if(p->val!=q->val) return false;
return isSameTree(p->left,q->left) && isSameTree(p->right,q->right);
}
};