Advertisement
AJMitev

Point in the Figure

Feb 5th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. using System;
  2.  
  3. class PointInTheFigure
  4. {
  5. static void Main()
  6. {
  7. int h = int.Parse(Console.ReadLine());
  8. int x = int.Parse(Console.ReadLine());
  9. int y = int.Parse(Console.ReadLine());
  10.  
  11. bool isItInside = x > 0 && x < h * 3 && y > 0 && y < h || x > h && x < h * 2 && y > 0 && y < h * 4;
  12. bool isItBorder = y == 0 && x >= 0 && x <= h * 3 || y == h && x >= 0 && x <= h
  13. || y == h && x >= h * 2 && x <= h * 3 || y == 4 * h && x >= h && x <= h * 2
  14. || x == h && y >= h && y <= h * 4 || x == h * 2 && y >= h && y <= h * 4
  15. || x == 0 && y >= 0 && y <= h || x == h * 3 && y >= 0 && y <= h; // First checking Top and bot and the ranges afther that checking sides
  16.  
  17. if (isItInside)
  18. {
  19. Console.WriteLine("inside");
  20. }
  21. else if (isItBorder)
  22. {
  23. Console.WriteLine("border");
  24. }
  25. else
  26. {
  27. Console.WriteLine("outside");
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement