C# 实现欧几里得距离(Euclidean Distance Score)

public void calculate(double[,] points)
{
  var distanceArray = new double[points.Length, points.Length];

  for (int i = 0; i < points.Length; i++)
    for (int j = 0; j < points.Length; j++)
      distanceArray[i, j] = Distance(points[i, 0], points[i, 1], points[j, 0], points[j, 1]);     

}

public static double Distance(double x1, double y1, double x2, double y2)
=>  Math.Sqrt(((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));   

你可能感兴趣的:(C#)