wes d2a2ba9e15 first commit 4 år sedan
..
README.md d2a2ba9e15 first commit 4 år sedan
code.cpp d2a2ba9e15 first commit 4 år sedan
unitTest.cpp d2a2ba9e15 first commit 4 år sedan

README.md

Negate the Vector of Numbers

by CppPythonDude tags: arrays, numbers, language_fundamentals, loops

Summary

Given a vector of numbers, negate all elements contained within. 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 +. Examples negate({1, 2, 3, 4}) ➞ {-1, -2, -3, -4} negate({-1, 2, -3, 4}) ➞ {1, -2, 3, -4} negate({}) ➞ {} Notes If you g

Instructions

Given a vector of numbers, negate all elements contained within.

  • 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 +.

Examples

negate({1, 2, 3, 4}) ➞ {-1, -2, -3, -4}

negate({-1, 2, -3, 4}) ➞ {1, -2, 3, -4}

negate({}) ➞ {}

Notes

If you get an empty vector, return an empty vector: {}