求大神帮忙指导一下这段代码,感激不尽。
想要达到的结果是将文本文件中的坐标读到数组中,然后根据坐标计算两点间的距离,菜鸟一个,求帮助。。。namespace wenbenwenjian
{
public struct Point
{
public double X;
public double Y;
}
class Program
{
static void Main(string[] args)
{
// Point[] pts = new Point[10];
List<Point> points = new List<Point>();
Point pt1 = new Point();
StreamReader sr = new StreamReader("11改.txt");
string content = sr.ReadToEnd();
string[] str = content.Split(new string[] { "\r\n" }, StringSplitOptions.None);
for (int i = 0; i < str.Length; i++)
{
Console.WriteLine("第 {0} 行: {1}", i + 1, str[i]);
Console.ReadLine();
}
pt1.X = Convert.ToDouble(str[1]);
pt1.Y = Convert.ToDouble(str[2]);
points.Add(pt1);
double dist = (points[1].Y - points[0].Y) * (points[1].Y - points[0].Y) + (points[1].X - points[0].X) * (points[1].X - points[0].X);
double RESULT = Math.Sqrt(Math.Abs(dist));
Console.WriteLine(RESULT);
Console.ReadKey();
}
}
}