Advertisement
dimipan80

Exam 8. Inside the Building

Jun 21st, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3. using System.Threading;
  4.  
  5. public class InsideTheBuilding
  6. {
  7.     public static void Main()
  8.     {
  9.         Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
  10.         checked
  11.         {
  12.             int size = int.Parse(Console.ReadLine());
  13.            
  14.             for (int i = 0; i < 5; i++)
  15.             {
  16.                 int pointX = int.Parse(Console.ReadLine());
  17.                 int pointY = int.Parse(Console.ReadLine());                
  18.  
  19.                 bool pointIsInsideBase = CheckThePointIsInsideTheBase(size, pointX, pointY);
  20.                 bool pointIsInsideTower = CheckThePointIsInsideTheTower(size, pointX, pointY);
  21.                 if (pointIsInsideBase || pointIsInsideTower)
  22.                 {
  23.                     Console.WriteLine("inside");
  24.                 }
  25.                 else
  26.                 {
  27.                     Console.WriteLine("outside");
  28.                 }
  29.             }
  30.         }
  31.     }
  32.  
  33.     private static bool CheckThePointIsInsideTheTower(int size, int pointX, int pointY)
  34.     {
  35.         checked
  36.         {
  37.             int minX = size, maxX = 2 * size;
  38.             int minY = size, maxY = 4 * size;
  39.             bool isInside = pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
  40.             return isInside;
  41.         }
  42.     }
  43.  
  44.     private static bool CheckThePointIsInsideTheBase(int size, int pointX, int pointY)
  45.     {
  46.         checked
  47.         {
  48.             int maxX = 3 * size;
  49.             int maxY = size;
  50.             bool isInside = pointX >= 0 && pointX <= maxX && pointY >= 0 && pointY <= maxY;
  51.             return isInside;
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement