Advertisement
Guest User

point in the figure

a guest
Feb 13th, 2018
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 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 Точка_във_фигурата
  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 x1 = 0;
  18.             var y1 = 0;
  19.             var x2 = 3 * h;
  20.             var y2 = h;
  21.             bool insidefigure1 = x > x1 && x < x2 && y > y1 && y < y2;
  22.             bool outsidefigure1 = x < x1 || x > x2 || y < y1 || y > y2;
  23.  
  24.             var x3 = h;
  25.             var y3 = h;
  26.             var x4 = 2 * h;
  27.             var y4 = 4 * h;
  28.             bool insidefigure2 = x > x3 && x < x4 && y > y3 && y < y4;
  29.             bool outsidefigure2 = x < x3 || x > x4 || y < y3 || y > y4;
  30.  
  31.             bool insideborder = x > x3 && x < x4 && y == y3;
  32.  
  33.             if (insidefigure1 || insidefigure2 || insideborder)
  34.             {
  35.                 Console.WriteLine("inside");
  36.             }
  37.             else if (outsidefigure1 && outsidefigure2)
  38.             {
  39.                 Console.WriteLine("outside");
  40.             }
  41.             else
  42.             {
  43.                 Console.WriteLine("border");
  44.             }
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement