Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.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 PointInTheFigure
  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.             //First Rectangle's Coordinates:
  18.             var x1 = 0;
  19.             var y1 = 0;
  20.             var x2 = 3 * h;
  21.             var y2 = 1 * h;
  22.  
  23.             //Second Rectangle's Coordinates:
  24.             var x3 = 1 * h;
  25.             var y3 = 1 * h;
  26.             var x4 = 2 * h;
  27.             var y4 = 4 * h;
  28.  
  29.             //Internal Border's Coordinates For The Rectangles:
  30.             var x5 = 1 * h;
  31.             var y5 = 1 * h;
  32.             var x6 = 2 * h;
  33.             //Borders of The Lower Rectangle:
  34.             var onLeftSide1 = ((x == x1) && (y >= y1 && y <= y2));
  35.             var onRightSide1 = ((x == x2) && (y >= y1 && y <= y2));
  36.             var onBottom1 = ((y == y1) && (x >= x1 && x <= x2));
  37.             var onTopLeft1 = ((y == y2) && (x >= x1 && x <= x3));
  38.             var onTopRight1 = ((y == y2) && (x >= x4 && x <= x2));
  39.  
  40.             //Borders of The Upper Rectangle Without Internal Border:
  41.             var onLeftSide2 = ((x == x3) && (y >= y3 && y <= y4));
  42.             var onRightSide2 = ((x == x4) && (y >= y3 && y <= y4));
  43.             var onTop2 = ((y == y4) && (x >= x3 && x <= x4));
  44.  
  45.  
  46.  
  47.             var internalBorder = ((y == y5) && (x > x5) && (x < x6));
  48.  
  49.             var insideRectang1 = ((x > x1) && (x < x2) && (y > y1) && (y < y2));
  50.  
  51.             var insideRectang2 = ((x > x3) && (x < x4) && (y > y3) && (y < y4));
  52.  
  53.             if (internalBorder || insideRectang1 || insideRectang2)
  54.             {
  55.                 Console.WriteLine("inside");
  56.             }
  57.             else if (onLeftSide1 || onRightSide1 || onBottom1 || onTopLeft1 || onTopRight1 || onLeftSide2 || onRightSide2 || onTop2)
  58.             {
  59.                 Console.WriteLine("border");
  60.             }
  61.             else
  62.             {
  63.                 Console.WriteLine("outside");
  64.             }
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement