+ 19
[CHALLENGE] negative numbers
Another simple challenge. Make all numbers negative except 0. You have integers: 42, -9, 29, -32, 19, 0 . Final data: -42, -9, -29, -32, -19, 0.
26 Answers
+ 17
https://code.sololearn.com/crtA722OkyyF/?ref=app
+ 13
I took a break from my favourite C++ and wrote in Ruby:
https://code.sololearn.com/c6Ly5ZQt79IT/?ref=app
+ 10
https://code.sololearn.com/cL0Q7ZpO9wZX/?ref=app
https://code.sololearn.com/ce1oQDP13CsV/?ref=app
+ 8
Hiya!
Did you submit this as an assignment via lesson factory? It would be great if you could!
+ 8
Here's another approach in C++, nice challenge. Thanks : )
https://code.sololearn.com/cGOUcDx3JJ0I/?ref=app
+ 7
Here is mine(Corrected):
https://code.sololearn.com/cTJWMaN5F58e/?ref=app
+ 7
+ 7
+ 6
Here's my try in c
https://code.sololearn.com/cCIFl5bBDvM4/?ref=app
+ 5
Your solution is not perfectly correct :) ALL numbers must be negative. Your last negative number in list becomes positive. Try to fix it.
+ 5
return (nbr==0)?0:Math.abs(nbr)*-1
+ 4
@A Z M Mushfiqur Rahman It is also not correct. You just rewrote it manually :) that's not good because when you add more numbers the code won't work.
+ 4
Here is my code in a more mathematical approach. Good challenge for learners!
https://code.sololearn.com/coUQH44O5hZJ/?ref=app
+ 4
In Python - simple and straight:
https://code.sololearn.com/cIIDn9HCIXPH/#py
+ 3
@jay I'll do it few minutes later :)
+ 3
@r8w9, correction is made in my code, please check now.
+ 3
Mine, used Linq =)
https://code.sololearn.com/c7r1SE1SSIMv/?ref=app
+ 3
@r8w9, thanks,I'm working on it.
+ 3
My try in C++
https://code.sololearn.com/cm4SXWK66Bgj/?ref=app