Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ничем не отличается от замены числа, возможны некоторые варианты, в зависимости от ввода
- void change_zero(const int old_id, const int new_element, const int x, const int lx, const int rx, vector<int>& array)
- {
- if (rx - lx == 1)
- {
- array[x] = new_element;
- return;
- }
- int m = (rx + lx) / 2;
- if (old_id < m)
- {
- set(old_id, new_element, 2 * x + 1, lx, m, array);
- }
- else
- {
- set(old_id, new_element, 2 * x + 2, m, rx, array);
- }
- array[x] = array[2 * x + 2] + array[2 * x + 1];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement