Wednesday 26 August 2020

Cats and a Mouse Hacker Rank Solution in C

https://www.hackerrank.com/challenges/cats-and-a-mouse/problem


#include<stdio.h>

#include<math.h>

int main()
{
    int q;
    scanf("%d",&q);
    while(q--)
    {
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        if(abs(x-z) < abs(y-z) )
            printf("Cat A\n");
        else if(abs(x-z) > abs(y-z))
            printf("Cat B\n");
        else
            printf("Mouse C\n");
    }
}

No comments:

Post a Comment