Advertisement
miroLLL

Point in the figure / 91p

Jan 26th, 2017
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4. * Created by LittleSucks on 26.1.2017 г..
  5. */
  6. public class p13_PointInTheFigure {
  7.  
  8. public static void main(String[] args) {
  9.  
  10. Scanner input = new Scanner(System.in);
  11.  
  12. int h = Integer.parseInt(input.nextLine());
  13. int x = Integer.parseInt(input.nextLine());
  14. int y = Integer.parseInt(input.nextLine());
  15.  
  16. // Borders check
  17.  
  18. boolean borderCheck1 = (y >= 0 && y <= h) && x == 0;
  19. boolean borderCheck2 = (y >= 0 && y <= h) && x == h * 3;
  20. boolean borderCheck3 = (x >= 0 && x <= h * 3) && y == 0;
  21. boolean borderCheck4 = (x >= 0 && x <= h * 3) && y == h;
  22. boolean borderCheck5 = (y >= 0 && y <= h * 4) && x == h;
  23. boolean borderCheck6 = (y >= 0 && y <= h * 4) && x == h * 2;
  24. boolean borderCheck7 = (y >= h * 2 && y <= h * 4) && x == h * 2;
  25. boolean borderCheck8 = (y >= h * 2 && y <= h * 4) && x == h * 3;
  26. boolean borderCheck9 = (y >= h * 2 && y <= h * 4) && x == h * 4;
  27.  
  28. boolean borderChecker = borderCheck1 || borderCheck2 || borderCheck3 || borderCheck4 ||
  29. borderCheck5 || borderCheck6 || borderCheck7 || borderCheck8 || borderCheck9;
  30. // end of borders check
  31.  
  32. // **************************************************************
  33.  
  34. // Inside check && don't touch the border
  35.  
  36. boolean insideCheck1 = (x > 0 && x < h * 3) && (y > 0 && y < h) && (x != h && x != h * 2);
  37. boolean insideCheck2 = (y > h && y < h * 4) && (x > h && x < h * 2) && (y != h * 2 && y != h * 3 && y != h * 4);
  38.  
  39. boolean insideChecker = insideCheck1 || insideCheck2;
  40.  
  41. // end of Inside check && don't touch the border
  42.  
  43. if (borderChecker) {
  44.  
  45. System.out.println("border");
  46.  
  47. } else if (insideChecker) {
  48.  
  49. System.out.println("inside");
  50.  
  51. } else if(!borderChecker && !insideChecker) {
  52.  
  53. System.out.println("outside");
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement