Advertisement
EntropyStarRover

13. Point in the Figure

Mar 31st, 2017
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4. * Created by entropy on 3/31/2017.
  5. */
  6. public class Heavy {
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9. int h = Integer.parseInt(scanner.nextLine());
  10. int x = Integer.parseInt(scanner.nextLine());
  11. int y = Integer.parseInt(scanner.nextLine());
  12.  
  13. boolean isInsidehorizontal = false;
  14. boolean isInsidevertical = false;
  15. boolean isBorderHorizontal = false;
  16. boolean isBorderVertical = false;
  17. boolean isBorder = false;
  18.  
  19. if ((x > 0 && x < 3 * h) && (y < h && y > 0)) {
  20. isInsidehorizontal = true;
  21. }
  22. if (((x >= 0) && (x <= 3 * h) && (y == 0 || y == h)) || ((y >= 0) && (y <= h)) && ((x == 0 || x == 3 * h))) {
  23. isBorderHorizontal = true;
  24.  
  25. }
  26.  
  27. if ((x > h) && (x < 2 * h) && (y < 4 * h && y > h)) {
  28. isInsidevertical = true;
  29. }
  30.  
  31. if (((x >= h) && (x <= 2 * h) && (y == 2 * h || y == 4 * h)) || ((y >= 2 * h) && (y <= 4 * h)) && ((x == h || x == 2 * h))) {
  32. isBorderVertical = true;
  33. }
  34.  
  35. if (isBorderHorizontal == true || isBorderVertical == true) {
  36. isBorder = true;
  37. System.out.println("border");
  38.  
  39. }
  40. if (isInsidehorizontal == true || isInsidevertical == true) {
  41. System.out.println("Inside");
  42. } else if (isBorder==false){
  43. System.out.println("Outside");
  44. }
  45.  
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement