Advertisement
Guest User

Untitled

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