GerganaTsirkova

PointInFigure

Oct 2nd, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.85 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 PointInTheFigure
  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.             //point inside
  17.             bool first = ((x < 3 * h) && (x > 0) && (y < h)) && (y > 0);
  18.             bool second = ((x > h) && (x < 2 * h) && (y == h));
  19.             bool third = ((x > h) && (x < 2 * h) && (y > h) && (y < 4 * h));
  20.             //point on a border
  21.             bool a = (x == 0) && (y >= 0) && ((y < h) || (y == h));
  22.             bool b = (y == 0) && ((x == 3 * h) || (x < 3 * h));
  23.             bool c = (y == h) && ((x < 3 * h) || (x == 3 * h))&&((x==2*h)||(x>2*h));
  24.             bool d = (x == 3 * h) && (y >= 0) && ((y < h) || (y == h));
  25.             bool e = (y == h) && ((x > 0) || (x == 0)) && ((x < h) || (x == h));
  26.             bool f = (y == 4 * h) && ((x == h) || (x > h)) && ((x < 2 * h) || (x == 2 * h));
  27.             bool g = (x == h) && ((y > h) || (y == h)) && ((y < 4 * h) || (y == 4 * h));
  28.             bool i = (x == 2 * h) && ((y == h) || (y > h)) && ((y < 4 * h) || (y == 4 * h));
  29.  
  30.             if ((x < 0) || (y < 0))
  31.             {
  32.                 Console.WriteLine("outside");
  33.             }
  34.             else if (  first==true||second==true  || third==true)
  35.             {
  36.                 Console.WriteLine("inside");
  37.             }
  38.             else if (a == true || b == true || c == true || d == true || e == true || f == true || g == true || i == true)
  39.             {
  40.                 Console.WriteLine("border");
  41.             }
  42.             else
  43.             {
  44.                 Console.WriteLine("outside");
  45.             }
  46.  
  47.  
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment