12345678910111213 |
- /* Given a vector, negate all the elements in the vector.
- * Negating a positive value -+n will return -n,
- * because all +'s are removed.
- * Negating a negative value --n will return n,
- * because the first - turns the second minus into a +.
- */
- std::vector<int> negate(std::vector<int> vi) {
- for (int dur = 0; dur<vi.size();dur++){
- vi[dur] = -vi[dur];
- }
- return vi;
- }
|