Пример #1
0
        private double GetDistance(ClosestPairOfPointsInPlane point1, ClosestPairOfPointsInPlane point2)
        {
            var x = point2.XCoordinate - point1.XCoordinate;
            var y = point2.YCoordinate - point1.YCoordinate;

            var distance = Math.Sqrt(x * x + y * y);

            return(distance);
        }
Пример #2
0
        public static void Main(string[] args)
        {
            var input = Convert.ToInt32(Console.ReadLine());
            ClosestPairOfPointsInPlane        pointObject = new ClosestPairOfPointsInPlane();
            List <ClosestPairOfPointsInPlane> pointsList  = new List <ClosestPairOfPointsInPlane>();

            for (int i = 0; i < input; i++)
            {
                var point = Console.ReadLine().Split(' ');
                pointsList.Add(new ClosestPairOfPointsInPlane(Convert.ToInt64(point[0]), Convert.ToInt64(point[1])));
            }
            var minDistance = pointObject.GetClosestPoints(pointsList, pointsList.Count);

            Console.WriteLine($"{minDistance:0.0000}");
        }