注册 登录
编程论坛 C++教室

Pathfinder的问题,请大神指点一二!

maxyu718 发布于 2013-11-22 08:31, 566 次点击
Pathfinder. Write a text-based program that reads a set of coordinates from a text file and outputs on the screen the path that can visit all the coordinates starting from the first coordinate in the file, and at every step moving to the nearest coordinate that has not been visited before. The maximum number of coordinates in the file is 10. The format of the text file consists of one coordinate per line where the x,y point is described by two integer numbers between 0 and 100 separated by a coma and with no blank spaces in between. For example, a file with a set of four coordinates will be as follows:
4,2
1,8
7,5
10,3
The path found by the program must start from 4,2 because it was the first coordinate in the list, and then it must continue to 7,5 because it is the closest coordinate to 4,2. Thus, the next coordinate must be 10,3 because it is the closest coordinate to 7,5. The final coordinate must be 1,8. The screen output should look like this: 4,2 --- 7,5 --- 10,3 --- 1,8. To run the program the user should type pathfinder <file_name>, where file_name is the file containing the coordinates.
这个是我们的一个project,但是我看不太懂,因为是菜鸟,求大神指点一二!谢谢啦
5 回复
#2
peach54602013-11-22 08:44
探路。写一个基于文本的程序,读取一组坐标的文本文件,并在屏幕上的输出路径,可以访问所有的坐标从文件中的第一个坐标,并在每一步移动到最近的坐标被访问过。在该文件中的坐标的最大数量为10。文本文件的格式由每行一个坐标的x,y点两个整数介于0和100由逗号分隔,之间没有空格。例如,一组四个坐标中的文件将是如下:
4,2
1,8
7,5
10,3
由程序找到的路径必须从4,2开始,因为它是列表中的第一个坐标,然后它必须继续,因为它是最接近的坐标为4,2 7,5 。因此,下一个坐标必须10,3 ,因为它是最接近的坐标为7,5 。最终的坐标必须是1,8 。屏幕输出看起来应该是这样的: 4,2 - 7,5 --- 10.3 --- 1,8 。要运行该程序,用户应输入探路者的删除<file_name> ,其中file_name是文件,其中包含的坐标。

谷歌翻译
#3
blueskiner2013-11-22 08:58
以下是引用peach5460在2013-11-22 08:44:01的发言:

探路。写一个基于文本的程序,读取一组坐标的文本文件,并在屏幕上的输出路径,可以访问所有的坐标从文件中的第一个坐标,并在每一步移动到最近的坐标被访问过。在该文件中的坐标的最大数量为10。文本文件的格式由每行一个坐标的x,y点两个整数介于0和100由逗号分隔,之间没有空格。例如,一组四个坐标中的文件将是如下:
4,2
1,8
7,5
10,3
由程序找到的路径必须从4,2开始,因为它是列表中的第一个坐标,然后它必须继续,因为它是最接近的坐标为4,2 7,5 。因此,下一个坐标必须10,3 ,因为它是最接近的坐标为7,5 。最终的坐标必须是1,8 。屏幕输出看起来应该是这样的: 4,2 - 7,5 --- 10.3 --- 1,8 。要运行该程序,用户应输入探路者的删除<file_name> ,其中file_name是文件,其中包含的坐标。

谷歌翻译

+1
#4
maxyu7182013-11-22 09:00
回复 2楼 peach5460
谢谢,我会google翻译,我想问这个具体应该怎么执行
#5
peach54602013-11-22 09:38
求代码?
#6
maxyu7182013-11-24 00:03
回复 5楼 peach5460
我是想了解一下这个project的思路,代码也可以。
1