Advertisement
Guest User

Untitled

a guest
Mar 19th, 2016
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. using System;
  2.  
  3. namespace PointInTheFigure
  4. {
  5. class Program
  6. {
  7. static void Main()
  8. {
  9. int input = int.Parse(Console.ReadLine());
  10. int x = int.Parse(Console.ReadLine());
  11. int y = int.Parse(Console.ReadLine());
  12.  
  13. int x1 = 0;
  14. int y1 = 0;
  15. int x2 = 3 * input;
  16. int y2 = input;
  17. int x3 = input;
  18. int y3 = input;
  19. int x4 = 2 * input;
  20. int y4 = 4 * input;
  21.  
  22. bool inRectA = (x > x1 && x < x2) && (y > y1 && y < y2); //Inside horizontal rectagle(RECTENGAL A)
  23.  
  24. bool inRectB = (x > x3 && x < x4) && (y > y3 && y < y4); //inside vertical rectangle(RECTENGAL B)
  25.  
  26. bool rectABorder = ((x == x1 || x == x2) && (y >= y1 && y <= y2)) ||
  27. ((y == y1 || y == y2) && (x >= x1 && x <= x2)); // rectengal A border
  28.  
  29. bool rectBBorder = ((x == x3 || x == x4) && (y >= y3 && y <= y4)) ||
  30. ((y == y3 || y == y4) && (x >= x3 && x <= x4)); // rectangle B border
  31.  
  32. bool exeption = ((y == y2) && (x > input && x < 2 * input)); /*this is the part of rect A border where
  33. Conncets to rect B witch must be "inisde"
  34. not "Border"*/
  35.  
  36.  
  37. if ( (rectABorder || rectBBorder)&&(!exeption))
  38. {
  39. Console.WriteLine("border");
  40. }
  41. else if (inRectA || inRectB||exeption)
  42. {
  43. Console.WriteLine("inside");
  44. }
  45. else
  46. {
  47. Console.WriteLine("outside");
  48. }
  49.  
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement