Martyn Shutt must be new here...
No ratings yet!
No if() Only abs()
This is the solution I came up with in C++; int largerNum(int x, int y){
} I decided it would be easier for me to get to the solution if I broke it up into individual parts. But working from that, as a single expression; return (abs((x - y - abs(pt1)) / (x/x + y/y))) + x; context |
No if() Only abs()
Correction; as a single return statement it should be return (abs((x - y - abs(x - y)) / (x/x + y/y))) + x; I accidentally left variable pt1 in there. context |
No if() Only abs()
But as highlighted in other posts, it doesn't work if either number is zero. It actually crashes my compiled application. Probably due to dividing by zero. context |