[해결로 표시] C# Point in a Circle

  

3
주제 스타터

Write an expression that checks if given point (x,  y) is inside a circle K({00}, 2).

Examples:

point in a circle in c#

1개 답글
2

Here is my solution:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
 
class PointInACircle
{
    static void Main()
    {
        Console.WriteLine("Enter point x for circle K({0, 0}, 2):");
        double x = double.Parse(Console.ReadLine());
        Console.WriteLine("Enter point y for circle K({0, 0}, 2):");
        double y = double.Parse(Console.ReadLine());
        bool check = Math.Pow((x - 0), 2) + Math.Pow((y - 0), 2) <= Math.Pow(2, 2);
        Console.WriteLine("Point inside? {0}", check);
    }
}
공유: