simonradev

PointInTheFigureV2

May 21st, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.11 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _16.Number0100ToText
  4. {
  5.     class Number0100ToText
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int h = int.Parse(Console.ReadLine());
  10.  
  11.             int x = int.Parse(Console.ReadLine());
  12.             int y = int.Parse(Console.ReadLine());
  13.  
  14.             int firstFigureX1 = 0;
  15.             int firstFigureX2 = h * 3;
  16.             int firstFigureY1 = 0;
  17.             int firstFigureY2 = h;
  18.  
  19.             bool pointIsInFirstFigure = x > firstFigureX1 && x < firstFigureX2 &&
  20.                                         y > firstFigureY1 && y < firstFigureY2;
  21.  
  22.             bool pointIsOnFirstFigureBorder = ((x == firstFigureX1 || x == firstFigureX2) && (y >= firstFigureY1 && y <= firstFigureY2)) ||
  23.                                               ((y == firstFigureY1 || y == firstFigureY2) && (x >= firstFigureX1 && x <= firstFigureX2));
  24.  
  25.  
  26.             int secondFigureX1 = h;
  27.             int secondFigureX2 = h * 2;
  28.             int secondFigureY1 = h;
  29.             int secondFigureY2 = h * 4;
  30.  
  31.             bool pointIsInSecondFigure = x > secondFigureX1 && x < secondFigureX2 &&
  32.                                          y >= secondFigureY1 && y < secondFigureY2;
  33.  
  34.             bool pointIsOnSecondFigureBorder = ((x == secondFigureX1 || x == secondFigureX2) && (y >= secondFigureY1 && y <= secondFigureY2)) ||
  35.                                                ((y == secondFigureY1 || y == secondFigureY2) && (x >= secondFigureX1 && x <= secondFigureX2));
  36.  
  37.             bool isInsideWholeFigure = pointIsInFirstFigure || pointIsInSecondFigure;
  38.             bool isOnBorderOfTheWholeFigure = pointIsOnFirstFigureBorder || pointIsOnSecondFigureBorder;
  39.            
  40.             if (isInsideWholeFigure)
  41.             {
  42.                 //vutre
  43.                 Console.WriteLine("inside");
  44.             }
  45.             else if (isOnBorderOfTheWholeFigure)
  46.             {
  47.                 //border
  48.                 Console.WriteLine("border");
  49.             }
  50.             else
  51.             {
  52.                 //vun
  53.                 Console.WriteLine("outside");
  54.             }
  55.         }
  56.     }
  57. }
Add Comment
Please, Sign In to add comment