namespace 计算两点间距离
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请您输入A点的x轴坐标:");
int x1 = Int32.Parse(Console.ReadLine());
Console.WriteLine("请您输入A点的y轴坐标:");
int y1 = Int32.Parse(Console.ReadLine());
Console.WriteLine("请您输入B点的x轴坐标:");
int x2 = Int32.Parse(Console.ReadLine());
Console.WriteLine("请您输入B点的y轴坐标:");
int y2 = Int32.Parse(Console.ReadLine());
Point p1 = new Point(x1,y1);
Point p2 = new Point(x2, y2);
Point p3 = new Point();
Console.WriteLine("A点的坐标:", p3.SetPoint(p1.X ,p1.Y ));
Console.WriteLine("B点的坐标:", p3.SetPoint(p2.X , p2.Y ));
Console.WriteLine( p3.DistanceToPoint(p1, p2));
}
}
}
class Point
{
private int x,y;
public int X
{
set { x = value; }
get { return x; }
}
public int Y
{
set { y = value; }
get { return y; }
}
public Point (int x,int y )
{
X = x;
Y = y;
}
public Point ()
{
}
public string SetPoint(int x, int y)
{
return "(" + x + "," + y + ")";
}
public double DistanceToPoint(Point p1,Point p2)
{
return Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2));
}
public string ConvertToString(Point p1,Point p2)
{
double result = DistanceToPoint(p1, p2);
string str = "A点的坐标:" + "(" + p1.X + "," + p1.Y + ")" + "点B的坐标:" + "(" + p2.X + "," + p2.Y + ")\n他们的距离是:" + result;
return str;
}
}

{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请您输入A点的x轴坐标:");
int x1 = Int32.Parse(Console.ReadLine());
Console.WriteLine("请您输入A点的y轴坐标:");
int y1 = Int32.Parse(Console.ReadLine());
Console.WriteLine("请您输入B点的x轴坐标:");
int x2 = Int32.Parse(Console.ReadLine());
Console.WriteLine("请您输入B点的y轴坐标:");
int y2 = Int32.Parse(Console.ReadLine());
Point p1 = new Point(x1,y1);
Point p2 = new Point(x2, y2);
Point p3 = new Point();
Console.WriteLine("A点的坐标:", p3.SetPoint(p1.X ,p1.Y ));
Console.WriteLine("B点的坐标:", p3.SetPoint(p2.X , p2.Y ));
Console.WriteLine( p3.DistanceToPoint(p1, p2));
}
}
}
class Point
{
private int x,y;
public int X
{
set { x = value; }
get { return x; }
}
public int Y
{
set { y = value; }
get { return y; }
}
public Point (int x,int y )
{
X = x;
Y = y;
}
public Point ()
{
}
public string SetPoint(int x, int y)
{
return "(" + x + "," + y + ")";
}
public double DistanceToPoint(Point p1,Point p2)
{
return Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2));
}
public string ConvertToString(Point p1,Point p2)
{
double result = DistanceToPoint(p1, p2);
string str = "A点的坐标:" + "(" + p1.X + "," + p1.Y + ")" + "点B的坐标:" + "(" + p2.X + "," + p2.Y + ")\n他们的距离是:" + result;
return str;
}
}

