CSharp · Console
using System;
using static System.Math;
Point p0 = new(),
p1 = new(1,1);
Console.WriteLine("Distance({0},{1}) == {2}", p0, p1, Distance(p0, p1));
// Note : nous sommes (implicitement) dans la classe Program, donc
// Distance est en fait Program.Distance
static double Distance(Point p0, Point p1) =>
Sqrt(Pow(p0.X - p1.X, 2) + Pow(p0.Y - p1.Y, 2)); // On va à l'essentiel
class Point
{
public double X { get; init; }
public double Y { get; init; }
public Point() : this(0, 0) {}
public Point(double x, double y)
{
X = x;
Y = y;
}
}