thegrudge

PointInACircle

Nov 11th, 2014
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3. class PointInACircle
  4. {
  5.     static void Main()
  6.     {
  7.         double x = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
  8.         double y = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
  9.         double r = 2; //given radius
  10.         //(x - center_x)^2 + (y - center_y)^2 < radius^2
  11.         bool isInCircle = Math.Pow((x - 0), 2) + Math.Pow((y - 0),2) <= r * r; //Math.Pow(x,2) = x*x
  12.         Console.WriteLine(isInCircle);
  13.  
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment