请教个问题,请诸位大神指教,谢谢了
定义一个点类,我编写了以下的程序:class Program
{
static void Main(string[] args)
{
int x2 = int.Parse(Console.ReadLine());
int y2= int.Parse(Console.ReadLine());
int z2 = int.Parse(Console.ReadLine());
Point p1 = new Point( );
Point p2 = new Point(x2, y2, z2);
double distance = p1.DistanceTo(p2);
Console.WriteLine(distance);
Console.ReadLine();
}
}
class Point
{
private int x;
private int y;
private int z;
public Point()
{
x =1 ;
y = 1 ;
z =1 ;
}
public Point(int k1, int j1, int m1)
{
x = k1;
y = j1;
z= m1;
}
public double DistanceTo(Point p)
{
int dx = x - p.x;
int dy = y - p.y;
int dz = z - p.z;
return Math.Sqrt(dx * dx + dy * dy + dz * dz);
}
}
运行由键盘输入可以得到输入坐标点到点(1,1,1)的距离,但是我想问的是能不能直接输入两个点的坐标,求出这俩个点的坐标?