1 bool compare(Node* left, Node* right) { 2 if (left == NULL && right != NULL) return false; 3 else if (left != NULL && right == NULL) return false; 4 else if (left == NULL && right == NULL) return true; 5 // 排除了空节点,再排除数值不相同的情况 6 else if (left->data_ != right->data_) return false; 7 return compare(left->left, right->right)&& compare(left->right, right->left); 8 }
标签:compare,right,return,二叉树,&&,对称,NULL,left From: https://www.cnblogs.com/Sandals-little/p/17601318.html