AleksandarKostadinov

14.Point_in_the_Figure

Jul 26th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.36 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 _14.Point_in_the_Figure
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.            
  14.            
  15.            
  16.            var h = int.Parse(Console.ReadLine());
  17.            var x = int.Parse(Console.ReadLine());
  18.            var y = int.Parse(Console.ReadLine());
  19.  
  20.             bool onRect1 = ((x == 0 || x == 3 * h) && (y >= 0 && y <= h)) || ((y == 0 || y == h) && (x >= 0 && x <=3 * h));
  21.             bool onRect2 = ((x == h || x == 2 * h) && (y >= h && y <= 4 * h)) || ((y == h || y == 4 * h) && (x >= h && x <= 2*h));
  22.             bool inside = ((x > 0 && x < 3 * h) && (y > 0 && y < h)) || ((x > h && x < 2 * h) && (y > h && y < 4 * h));
  23.             int  place = -1;
  24.  
  25.             if (onRect1 || onRect2)
  26.             {
  27.                 place = 0;
  28.             }
  29.             if (y==h&&x>h&&x<2*h)
  30.             {
  31.                 place = 1;
  32.             }
  33.             if (inside)
  34.             {
  35.                 place = 1;
  36.             }
  37.            
  38.             switch (place)
  39.             {
  40.  
  41.                 case -1: Console.WriteLine("outside"); break;
  42.                 case 0: Console.WriteLine("border");break;
  43.                 case 1: Console.WriteLine("inside"); break;
  44.             }
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment