Advertisement
desislava_topuzakova

01. Point on Rectangle Border

May 3rd, 2020
672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConditionalStatementsAdvanced
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             //x1, y1, x2, y2, x и y
  10.             double x1 = double.Parse(Console.ReadLine());
  11.             double y1 = double.Parse(Console.ReadLine());
  12.             double x2 = double.Parse(Console.ReadLine());
  13.             double y2 = double.Parse(Console.ReadLine());
  14.             double x = double.Parse(Console.ReadLine());
  15.             double y = double.Parse(Console.ReadLine());
  16.          
  17.  
  18.             //Border -> 1 точка или 2 точка
  19.             //1 точка -> x съвпада с x1 или x2 -> x == x1 || x == x2
  20.             //и
  21.             //y е между y1 и y2 -> y >= y1 && y <= y2
  22.             //2 точка -> y съвпада с y1 или y2 -> y == y1 || y == y2
  23.             //и
  24.             //същевременно x е между x1 и x2 -> x >= x1 && x <= x2
  25.  
  26.             bool condition1 = (x == x1 || x == x2) && (y >= y1 && y <= y2);
  27.             bool condition2 = (y == y1 || y == y2) && (x >= x1 && x <= x2);
  28.  
  29.             if(condition1 || condition2)
  30.             {
  31.                 Console.WriteLine("Border");              
  32.             }
  33.             else
  34.             {
  35.                 Console.WriteLine("Inside / Outside");
  36.             }
  37.  
  38.  
  39.  
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement