code-problem-solutions/hackerrank.cats.and.a.mouse...

8 lines
161 B
C++
Raw Normal View History

2021-05-07 16:19:28 +00:00
string catAndMouse(int x, int y, int z) {
if (abs(x-z) > abs(y-z))
return "Cat B";
else if (abs(x-z) < abs(y-z))
return "Cat A";
else return "Mouse C";
}