Advertisement
rado8506

06. Point on Rectangle Border - alternative

Jan 22nd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 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 ConsoleApp5
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double x1 = double.Parse(Console.ReadLine());
  14.             double y1 = double.Parse(Console.ReadLine());
  15.             double x2 = double.Parse(Console.ReadLine());
  16.             double y2 = double.Parse(Console.ReadLine());
  17.  
  18.             double x = double.Parse(Console.ReadLine());
  19.             double y = double.Parse(Console.ReadLine());
  20.  
  21.             var side1 = (x == x1) && (y >= y1) && (y <= y2);
  22.             var side2 = (x == x2) && (y >= y1) && (y <= y2);
  23.             var side3 = (y == y1) && (x >= x1) && (x <= x2);
  24.             var side4 = (y == y2) && (x >= x1) && (x <= x2);
  25.  
  26.             if (side1 || side2 || side3 || side4)
  27.             {
  28.                 Console.WriteLine("Border");
  29.             }
  30.             else
  31.             {
  32.                 Console.WriteLine("Inside / Outside");
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement