Advertisement
Pazzobg

Programming Basics / 4.Complex-Conditions / 13.PointFigure2

Feb 14th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _0._0._1.Practice
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var h = int.Parse(Console.ReadLine());
  10.             var x = int.Parse(Console.ReadLine());
  11.             var y = int.Parse(Console.ReadLine());
  12.  
  13.             var botXstart = 0;
  14.             var botXend = 3 * h;
  15.             var botYstart = 0;
  16.             var botYend = h;
  17.  
  18.             var topXstart = h;
  19.             var topXend = 2 * h;
  20.             var topYstart = h;
  21.             var topYend = 4 * h;
  22.  
  23.             var inBotRectangle = (x > botXstart && x < botXend) && (y > botYstart && y < botYend);
  24.             var inTopRectangle = (x > topXstart && x < topXend) && (y > topYstart && y < topYend);
  25.             var middleLine = (x > h && x < 2 * h && y == h);
  26.  
  27.             var onBotBorderXdown = (x >= 0 && x <= 3 * h && y == 0);
  28.             var onBotBorderXUp = (((x >= 0 && x <= h) || (x >= 2 * h && x <= 3 * h)) && y == h);
  29.             var onBotBorderYboth = ((y >= 0 && y <= h) && x == 0) || ((y >= 0 && y <= h) && x == 3 * h);
  30.             var onTopBorderXUp = (x >= h && x <= 2 * h) && y == 4 * h;
  31.             var onTopBorderYleft = ((y > h && y < 4 * h) && x == h);
  32.             var onTopBorderYright = ((y > h && y < 4 * h) && x == 2 * h);
  33.  
  34.             if (inBotRectangle || inTopRectangle || middleLine)
  35.             {
  36.                 Console.WriteLine("inside");
  37.             }
  38.             else if (onBotBorderXdown || onBotBorderXUp || onBotBorderYboth || onTopBorderXUp || onTopBorderYleft || onTopBorderYright)
  39.             {
  40.                 Console.WriteLine("border");
  41.             }
  42.             else
  43.             {
  44.                 Console.WriteLine("outside");
  45.             }
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement