# Why WA in DCP-341: Square

Dev Skill archived problems can be discussed here.

### Why WA in DCP-341: Square

I am trying to solve DCP-341: Square problem . My code is as following :
Code: Select all
`class MyClass {   public static void main(String[] args) throws java.lang.Exception {      Scanner in = new Scanner(System.in);      int test = in.nextInt();      for (int i = 0; i < test; i++) {         double xA, yA, xB, yB;         xA = in.nextDouble();         yA = in.nextDouble();         xB = in.nextDouble();         yB = in.nextDouble();         double xDiff = Math.abs(xA - xB);         double yDiff = Math.abs(yA - yB);         if (xDiff == yDiff) {            System.out.println((int) (xDiff - (int) xDiff / 2));         } else {            double side = Math.min(xDiff, yDiff);            System.out.println((int) side);         }      }      in.close();   }}`

My observation for the following input is depicted in the picture :

1
3 7 5 10
The answer will be 2 for the above input as depicted int the picture attached with this post .Where is the error ?

Where is the error in my code ?

Posts: 1
Joined: Wed Jun 14, 2017 1:06 pm

### Re: Why WA in DCP-341: Square

You may assume that you may make one "0" length square.

Posts: 43
Joined: Tue Jan 17, 2017 10:10 pm

### Re: Why WA in DCP-341: Square

The correct output for the input
Code: Select all
`13 7 5 10 `
is 3

Posts: 11
Joined: Thu Jun 15, 2017 3:37 pm

Who is online
Users browsing this forum: No registered users and 1 guest