IN PYHTON IT WILL BE :
def catAndMouse(x,y,z):
if abs(x-z)abs(y-z):
print(“Cat B”)
else:
print(“Mouse C”)
n = int(input())
for i in range(n):
x,y,z = list(map(int,input().split()))
catAndMouse(x,y,z)
n=int(input())
m=[]
for i in range(n):
x=list(map(int,input().split(” “)))
m.append(x)
print(m)
def catAndMouse(e):
if abs(e[2]-e[1])<abs(e[2]-e[0]):
return("Cat B")
if abs(e[2]-e[0])<abs(e[2]-e[1]):
return("Cat A ")
if abs(e[2]-e[0])==abs(e[2]-e[1]):
return("Mouse C")
for i in m:
n1=catAndMouse(i)
print(n1)
#Python
n=int(input())
while n>0:
a,b,c=map(int,input().split(” “))
x=abs(a-c)
y=abs(b-c)
if x>y:
print(“Cat B”)
elif x<y:
print("cat A")
else:
print("Mouse C")
n-=1
IN PYHTON IT WILL BE :
def catAndMouse(x,y,z):
if abs(x-z)abs(y-z):
print(“Cat B”)
else:
print(“Mouse C”)
n = int(input())
for i in range(n):
x,y,z = list(map(int,input().split()))
catAndMouse(x,y,z)
Python Code
x=int(input(‘Postion of Cat A ‘))
y=int(input(‘Postion of Cat B ‘))
z=int(input(‘Postion of Mouse ‘))
if abs(y-z) > abs(x-z):
print(‘Cat A ‘)
elif abs(y-z) < abs(x-z):
print('Cat B ')
else :
print('Mouse Escapes ')
#include
#include
#include
void catandmouse(int x,int y,int z)
{
x=abs(z-x);
y=abs(z-y);
if(x<y)
printf("\nCAT A");
else if(y<x)
printf("\nCAT B");
else
printf("\nMouse C Escapes");
}
int main()
{
int x=0,y=0,z=0,q=2;
while(q)
{
printf("\nEnter the values of x,y and z\n");
scanf("%d%d%d", &x,&y,&z);
catandmouse(x,y,z);
q–;
}
return 0;
}
n=int(input())
m=[]
for i in range(n):
x=list(map(int,input().split(” “)))
m.append(x)
print(m)
def catAndMouse(e):
if abs(e[2]-e[1])<abs(e[2]-e[0]):
return("Cat B")
if abs(e[2]-e[0])<abs(e[2]-e[1]):
return("Cat A ")
if abs(e[2]-e[0])==abs(e[2]-e[1]):
return("Mouse C")
for i in m:
n1=catAndMouse(i)
print(n1)
#include
using namespace std;
int catandmouse(int x,int y,int z){
x = (z-x);
y = (z-y);
if(x>y){
cout<<"CAT B"<x){
cout<<"CAT A"<<endl;
}
else{
cout<<"MOUSE C"<>q;
while(q–){
int x,y,z;
cin>>x>>y>>z;
catandmouse(x,y,z);
}
return 0;
}
Thanks for contributing your code Shreyash
#include
#include
int main()
{
int n,a[10],x,y,z;
scanf(“%d”,&n);
while(n)
{
for(int i=0;iy)
{
printf(“cat B”);
}
else
{
printf(“cat A”);
}
–n;
}
return 0;
}