using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
public class Point
{
private int x;
private int y;
public Point()
{
x = 0;
y = 0;
}
public Point(int v, int h)
{
x = v;
y = h;
}
public int X
{
get { return x; }
set { x = value;}
}
public int Y
{
get { return y; }
set { y = value;}
}
public void ShowPoint()
{
Console.WriteLine("横坐标是{0},纵坐标是{1}",x,y);
}
}
}
......
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Point pointOne = new Point();
Point pointTwo = new Point(4, 3);
pointOne.X = 5;
pointOne.Y = 12;
pointOne.ShowPoint();
pointTwo.ShowPoint();
int disOne =Convert.ToInt32(System.Math.Pow((pointOne.X - pointTwo.X),2.0));
int disTwo =Convert.ToInt32(System.Math.Pow((pointOne.Y - pointTwo.Y),2.0));
int distance =Convert.ToInt32(System.Math.Sqrt(disOne + disTwo));
Console.WriteLine("两个点之间的距离为:{0}", distance);
}
}
}