grach

PointOnRectangleBorder

Jul 11th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.88 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 PointAtRectangularSide
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {      
  13.             var x1 = double.Parse(Console.ReadLine());
  14.             var y1 = double.Parse(Console.ReadLine());
  15.             var x2 = double.Parse(Console.ReadLine());
  16.             var y2 = double.Parse(Console.ReadLine());
  17.                      
  18.              var x = double.Parse(Console.ReadLine());
  19.              var y = double.Parse(Console.ReadLine());
  20.  
  21.             var checkx = (x == x1 || x == x2);
  22.             var checky = (y == y1 || y == y2);
  23.  
  24.             var checkxrange = (x >= x1) && (x <= x2);
  25.             var checkyrange = (y >= y1) && (y <= y2);
  26.  
  27.  
  28.             if ( (checkx && checkxrange && checkyrange)
  29.                                                ||
  30.                 (checky && checkyrange && checkxrange) )
  31.  
  32.             {
  33.                 Console.WriteLine("Border");
  34.             }
  35.  
  36.             else Console.WriteLine("Inside / Outside");
  37.         }
  38.     }
  39. }
  40.  
  41.  /* var x1 = double.Parse(Console.ReadLine());
  42.             var y1 = double.Parse(Console.ReadLine());
  43.             var x2 = double.Parse(Console.ReadLine());
  44.             var y2 = double.Parse(Console.ReadLine());
  45.                      
  46.              var x = double.Parse(Console.ReadLine());
  47.              var y = double.Parse(Console.ReadLine());
  48.  
  49.             {
  50.                 if (((x == x1 || x == x2) &&
  51.                    (y >= y1) && (y <= y2))
  52.                                     ||
  53.                     ((y == y1 || y == y2) &&
  54.                     (x >= x1) && (x <= x2)))
  55.  
  56.                 {
  57.                     Console.WriteLine("Border");
  58.                 }
  59.                 else Console.WriteLine("Inside / Outside");
  60.             }
  61.         }
  62.     }
  63. }
  64.     */
Advertisement
Add Comment
Please, Sign In to add comment