drunin89

13. PointInTheFigure

Nov 8th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 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_Figure
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var h = int.Parse(Console.ReadLine());
  14.             var x = int.Parse(Console.ReadLine());
  15.             var y = int.Parse(Console.ReadLine());
  16.  
  17.             var insideFirstRectangle = (x > 0 && x < 3 * h) && (y > 0 && y < h);
  18.             var insideSecondRectangle = (x > h && x < 2 * h) && (y > h && y < 4 * h);
  19.             var onMiddleSide = (x > h && x < 2 * h && y == h);
  20.  
  21.             var outsideFirstRectangle = (x < 0 || x > 3 * h) || (y < 0 || y > h);
  22.             var outsideSecondRectangle = (x < h || x > 2 * h) || (y < h || y > 4 * h);
  23.  
  24.             if (insideFirstRectangle || insideSecondRectangle || onMiddleSide)
  25.             {
  26.                 Console.WriteLine("inside");
  27.             }
  28.             else if (outsideFirstRectangle && outsideSecondRectangle)
  29.             {
  30.                 Console.WriteLine("outside");
  31.             }
  32.             else
  33.             {
  34.                 Console.WriteLine("border");
  35.             }
  36.         }
  37.     }
  38. }
Add Comment
Please, Sign In to add comment