Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int difference(TNode<int>* r, int x, int y,int count)
- {
- int sum = 1;
- if (r == nullptr)
- {
- return sum;
- }
- if (r->left == nullptr && r->right == nullptr)
- {
- if (count % 2 == 0)
- {
- sum *= r->data;
- }
- }
- sum *= difference(r->left, x, y, count);
- if (r->data >= x && r->data <= y)
- {
- count++;
- }
- sum *= difference(r->right, x, y, count);
- return sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement