BorislavBorisov

07.02.Inside The Building авторско

Nov 8th, 2015
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using System;
  2.  
  3. class InsideTheBuilding
  4. {
  5.     static void Main()
  6.     {
  7.         int size = int.Parse(Console.ReadLine());
  8.         int x1 = int.Parse(Console.ReadLine());
  9.         int y1 = int.Parse(Console.ReadLine());
  10.         int x2 = int.Parse(Console.ReadLine());
  11.         int y2 = int.Parse(Console.ReadLine());
  12.         int x3 = int.Parse(Console.ReadLine());
  13.         int y3 = int.Parse(Console.ReadLine());
  14.         int x4 = int.Parse(Console.ReadLine());
  15.         int y4 = int.Parse(Console.ReadLine());
  16.         int x5 = int.Parse(Console.ReadLine());
  17.         int y5 = int.Parse(Console.ReadLine());
  18.  
  19.         Console.WriteLine(IsPointInTheBuilding(x1, y1, size));
  20.         Console.WriteLine(IsPointInTheBuilding(x2, y2, size));
  21.         Console.WriteLine(IsPointInTheBuilding(x3, y3, size));
  22.         Console.WriteLine(IsPointInTheBuilding(x4, y4, size));
  23.         Console.WriteLine(IsPointInTheBuilding(x5, y5, size));
  24.     }
  25.  
  26.     private static string IsPointInTheBuilding(int x, int y, int size)
  27.     {
  28.         bool insideDown = (x >= 0) && (x <= 3 * size) && (y >= 0) && (y <= size);
  29.         bool insideUp = (x >= size) && (x <= 2 * size) && (y >= size) && (y <= 4 * size);
  30.         bool inside = insideDown | insideUp;
  31.         string result = inside ? "inside" : "outside";
  32.         return result;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment