-
Notifications
You must be signed in to change notification settings - Fork 6
/
Solution.cs
54 lines (43 loc) · 1.05 KB
/
Solution.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
class Solution {
// Complete the catAndMouse function below.
static string catAndMouse(int x, int y, int z) {
int xdis=0;
int ydis=0;
string a= "Cat A";
string b= "Cat B";
string c= "Mouse C";
if(x<z){
xdis=z-x;
}
else if(x>z){
xdis=x-z;
}
if(y<z){
ydis=z-y;
}
else if(y>z){
ydis=y-z;
}
if(xdis<ydis){
return a;
}
else if(xdis>ydis){
return b;
}
else {
return c;
}
}
static void Main(string[] args) {
int q = Convert.ToInt32(Console.ReadLine());
for (int qItr = 0; qItr < q; qItr++) {
string[] xyz = Console.ReadLine().Split(' ');
int x = Convert.ToInt32(xyz[0]);
int y = Convert.ToInt32(xyz[1]);
int z = Convert.ToInt32(xyz[2]);
string result = catAndMouse(x, y, z);
Console.WriteLine(result);
}
}
}