Advertisement
Sim0o0na

Untitled

Jan 24th, 2017
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. package ComplexConditionalStatements;
  2.  
  3. import java.util.*;
  4.  
  5. public class PointInTheFigure {
  6.  
  7.     public static void main(String[] args) {
  8.         // TODO Auto-generated method stub
  9.         Scanner input = new Scanner(System.in);
  10.  
  11.         int h = Integer.parseInt(input.nextLine());
  12.         int x = Integer.parseInt(input.nextLine());
  13.         int y = Integer.parseInt(input.nextLine());
  14.  
  15.         // dolen pravougulnik
  16.         int x1dolen = 0;
  17.         int y1dolen = 0;
  18.         int x2dolen = x1dolen + 3 * h;
  19.         int y2dolen = y1dolen + h;
  20.  
  21.         // shared wall
  22.         int border1x = x1dolen + h;
  23.         int border1y = y1dolen + h;
  24.         int border2x = x1dolen + 2 * h;
  25.  
  26.         // goren pravougulnik
  27.         int x1goren = 2 * h;
  28.         int y1goren = 4 * h;
  29.         int x2goren = x1dolen + h;
  30.         int y2goren = y1goren - 3 * h;
  31.  
  32.         if ((x > x1goren && x < x2goren && y > y1goren && y < y2goren)
  33.                 || ((x > border1x && x < border2x ))
  34.                 || (x > x1dolen && x < x2dolen && y > y1dolen && y < y2dolen)) {
  35.             System.out.println("Inside");
  36.         }
  37.  
  38.         else if (!(x >= x1dolen && x <= x2dolen && y >= y1dolen && y <= y2dolen)) {
  39.             System.out.println("Outside");
  40.         }
  41.  
  42.         else if ((x == x1dolen || x == x2dolen || y == y1dolen || y == y2dolen) || ((x == border1x && x == border2x ))
  43.                 || (x == x1goren && x == x2goren && y == y1goren && y == y2goren))
  44.             System.out.println("Border");
  45.     }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement