Advertisement
YavorGrancharov

PointInTheFigure

Jan 22nd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PointInTheFigure {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.         int h = Integer.parseInt(console.nextLine());
  7.         int x = Integer.parseInt(console.nextLine());
  8.         int y = Integer.parseInt(console.nextLine());
  9.  
  10.         //figOne
  11.         int x1 = 0;
  12.         int y1 = 0;
  13.         int x2 = h * 3;
  14.         int y2 = h;
  15.  
  16.         //figTwo
  17.         int x3 = h;
  18.         int y3 = h;
  19.         int x4 = h * 2;
  20.         int y4 = (h * 4);
  21.  
  22.         boolean isInside = ((x > x1 && x < x2 && y > y1 && y < y2) || (x > x3 && x < x4 && y > y3 && y < y4) || (y == y2 && x3 < x && (x3 * 2) > x));
  23.         boolean border = ((y == y1 && x >= x1 && x <= x2) || (y == y2 && (x >= x1 && x <= x3)) || (y == y2 && (x >= x4 && x <= x2)) || ((x == x1 || x == x2 )&& y1 <= y && y <= y2) || (y == y4 && x >= x3 && x <= x4) || (x == x3 && y >= y3 && y <= y4) || (x == x4 && y >= y3 && y <= y4));
  24.  
  25.         if (isInside) {
  26.             System.out.println("inside");
  27.         } else if (border) {
  28.             System.out.println("border");
  29.         } else {
  30.             System.out.println("outside");
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement