Yasen6275

point in figure

Feb 10th, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.52 KB | None | 0 0
  1. using System;
  2.  
  3. namespace cinema
  4. {
  5.     class MainClass
  6.     {
  7.         public static Boolean Inside (double [,] data){
  8.             if ((data[2,0]<data[1,0])&&(data[2,0]>data[0,0])&&(data[2,1]<data[1,1])&&(data[2,1]>data[0,1])) {
  9.                 return(true);
  10.             } else {
  11.                 return(false);       
  12.             }
  13.         }
  14.         public static Boolean Border (double [,] c){
  15.             Boolean left = ((c [2, 0] == c [0, 0]) && (c [2, 1] <= c [1, 1]) && (c [2, 1] >= c [0, 1]));
  16.             Boolean Right = ((c [2, 0] == c [1, 0]) && (c [2, 1] <= c [1, 1]) && (c [2, 1] >= c [0, 1]));
  17.             Boolean Top = ((c [2, 1] == c [1, 1]) && (c [2, 0] <= c [1, 0]) && (c [2, 0] >= c [0, 0]));
  18.             Boolean Bottom = ((c [2, 1] == c [0, 1]) && (c [2, 0] <= c [1, 0]) && (c [2, 0] >= c [0, 0]));
  19.             if (left || Right || Top || Bottom) {
  20.                 return(true);
  21.             } else {
  22.                 return(false);
  23.             }
  24.         }
  25.         public static void Main (string[] args)
  26.         {
  27.             var h = double.Parse(Console.ReadLine ());
  28.             var x = double.Parse(Console.ReadLine ());
  29.             var y = double.Parse(Console.ReadLine ());
  30.             double[,] coords = new double[3, 2] { { 0.0, 0.0 }, { 3.0 * h, h }, { x, y } };
  31.             Boolean horizontal = Inside (coords);
  32.             Boolean hborder = Border (coords);
  33.             coords = new double[3, 2] {{ h, h }, { 2.0 * h, 4.0 * h }, { x, y } };
  34.             Boolean Vertical = Inside(coords);
  35.             Boolean vborder = Border (coords);
  36.             if ((horizontal||Vertical)||(y==h&&x>h&&x<(2*h))) {
  37.                 Console.WriteLine ("inside");
  38.             } else if (hborder||vborder) {
  39.                 Console.WriteLine ("border");
  40.             } else {
  41.                 Console.WriteLine ("outside");
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment