using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CcalculateDistance
{
class Tpoint
{
private int x;
private int y;
public Tpoint(int x1, int y1)
{
x = x1;
y = y1;
}
public float EuclideanDistance(Tpoint tpoint)
{
return (float)Math.Sqrt((x - tpoint.x) * (x - tpoint.x) + (y - tpoint.y) * (y - tpoint.y));
}
public float ManhattanDistance(Tpoint tpoint)
{
return (float)(Math.Abs(x - tpoint.x) + Math.Abs(y - tpoint.y));
}
public float CosDistance(Tpoint tpoint)
{
return (float)((x * tpoint.x + y * tpoint.y) / (Math.Sqrt(x * x + tpoint.x * tpoint.x) * Math.Sqrt(y * y + tpoint.y * tpoint.y)));
}
}
class Program
{
static void Main(string[] args)
{
Tpoint point1 = new Tpoint(1,1), point2 = new Tpoint(2,2);
Console.WriteLine("点(1,1)和点(2,2)之间的欧氏距离是:{0}",point1.EuclideanDistance(point2));
Console.WriteLine("点(1,1)和点(2,2)之间的曼哈顿距离是:{0}", point1.ManhattanDistance(point2));
Console.WriteLine("点(1,1)和点(2,2)之间的余弦距离是:{0}", point1.CosDistance(point2));
}
}
}