'(C++ vectors) How to assign values in a range of elements inside a vector?

I have a vector of ints, like {0, 0, 0, 0, 0}. I need to increase v[i] by 1 for a range of elements, like v[1] to v[3] so that I have {0, 1, 1, 1, 0}. How to do that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source