wes d2a2ba9e15 first commit | 4 anni fa | |
---|---|---|
.. | ||
README.md | 4 anni fa | |
code.cpp | 4 anni fa | |
unitTest.cpp | 4 anni fa |
by CppPythonDude tags: arrays, numbers, language_fundamentals, loops
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
Given a vector of numbers, negate all elements contained within.
-+n
will return -n
, because all +
's are removed.--n
will return n
, because the first -
turns the second minus into a +
.negate({1, 2, 3, 4}) ➞ {-1, -2, -3, -4}
negate({-1, 2, -3, 4}) ➞ {1, -2, 3, -4}
negate({}) ➞ {}
If you get an empty vector, return an empty vector: {}