LardaX

Point-in-the-Figure

Jul 4th, 2016
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Point_in_the_Figure
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int h = int.Parse(Console.ReadLine());
  14.             int x = int.Parse(Console.ReadLine());
  15.             int y = int.Parse(Console.ReadLine());
  16.  
  17.             var onLeftSide = (x == 0) && (y >= 0) && (y <= h);
  18.             var onRightSide = (x == 3 * h) && (y >= 0) && (y <= h);
  19.             var onUpSide = (y == h) && ((x >= 0 && x <= h) || (x >= 2 * h && x <= 3 * h));
  20.             var onDownSide = (y == 0) && (x >= 0) && (x <= 3 * h);
  21.  
  22.             var onLeftSideTop = (x == h) && (y >= h) && (y <= 4 * h);
  23.             var onRightSideTop = (x == 2 * h) && (y >= h) && (y <= 4 * h);
  24.             var onTopSide = (y == 4 * h) && (x >= h) && (x <= 2 * h);
  25.  
  26.             if ((x > 0 && x < 3 * h && y > 0 && y < h) || (x > h && x < 2 * h && y > 0 && y < 4 * h ))
  27.             {
  28.                 Console.WriteLine("inside");
  29.             }
  30.             else if (onLeftSide || onLeftSideTop || onRightSide || onRightSideTop || onUpSide || onDownSide || onTopSide)
  31.             {
  32.                 Console.WriteLine("border");
  33.             }
  34.             else
  35.             {
  36.                 Console.WriteLine("outside");
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment