Advertisement
ivanov_ivan

PointInsideACircleOutsideOfARectangle

Jan 26th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 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 PointInsideACircleOutsideOfARectangle
  8. {
  9.     class PointInsideACircleAndOutsideOfARectangle
  10.     {
  11.         static void Main()
  12.         {
  13.             double xPoint = double.Parse(Console.ReadLine());
  14.             double yPoint = double.Parse(Console.ReadLine());
  15.             double xCirclePoint = 0;
  16.             double yCirclePoint = 0;
  17.             double radius = 5.0D;
  18.             double areInside = Math.Pow(( xPoint - xCirclePoint ) , 2) + Math.Pow(( yPoint - yCirclePoint ) , 2);
  19.  
  20.             bool insideCircle = areInside <= Math.Pow(radius , 2);
  21.             bool insideRectangle = ( xPoint >= -1 && xPoint <= 5 ) && ( yPoint >= -1 && yPoint <= 5 );
  22.  
  23.             if(insideCircle && insideRectangle == false)
  24.             {
  25.                 Console.WriteLine("The point is within the circle and out of the rectangle ");
  26.             }
  27.             else
  28.             {
  29.                 Console.WriteLine(false);
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement