+ 1

does anybody knows how to do it without restrictions? describe your way..

https://code.sololearn.com/cbNc1QQBq6U0/?ref=app

23rd Oct 2017, 8:42 PM
kronos
kronos - avatar
2 Respuestas
+ 2
When you subtract the variables a and b from eachother in: c=(a-b)/2; Take the absolute value of a - b instead. c = abs(a - b) / 2; That way the order doesn't matter. You can use abs from cmath, by writing #include <cmath> at the top of your program. PS: I recommend using meaningful variable names.
23rd Oct 2017, 9:59 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
here is a more simple solution i just came up https://code.sololearn.com/cHgkLjUSOOOi/?ref=app
25th Oct 2017, 9:25 PM
kronos
kronos - avatar