Advertisement
VanessaShopping

Point in the Figure

Feb 9th, 2016
750
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 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.         // First Figure
  11.         int x1 = h;
  12.         int x2 = 2 * h;
  13.         int y1 = 4 * h;
  14.         int y2 = 7 * h;
  15.         // Second Figure
  16.         int a1 = 0;
  17.         int a2 = 3 * h;
  18.         int b1 = 7 * h;
  19.         int b2 = 8 * h;
  20.         // Border
  21.         var right = (x == x1) && (y >= y1) && (y <= y2) || (x == a1) && (y >= b1) && (y <= b2);
  22.         var left = (x == x2) && (y >= y1) && (y <= y2) || (x == a2) && (y >= b1) && (y <= b2);
  23.         var up = (y == y1) && (x >= x1) && (x <= x2) || (y == b2) && (x >= a1) && (x <= a2);
  24.         var down = (y == y2) && (x >= x1) && (x <= x2) || (y == b2) && (x >= a1) && (x <= a2);
  25.         // Inside
  26.         var inside = ((x > x1 && x < x2 && y > y1 && y < y2) || (x > a1 && x < a2 && y > b1 && y < b2));
  27.  
  28.         if (right || left || up || down)
  29.         {
  30.             Console.WriteLine("border");
  31.         }
  32.         else if (inside)
  33.         {
  34.             Console.WriteLine("inside");
  35.         }
  36.         else
  37.         {
  38.             Console.WriteLine("outside");
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement