+ 1
does anybody knows how to do it without restrictions? describe your way..
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.
+ 1
here is a more simple solution i just came up
https://code.sololearn.com/cHgkLjUSOOOi/?ref=app