• 主页
• 问答

# 有一道关于跳棋的遍历问题

dyingswan 2010-07-29 09:31:15

int p[17][25]={
0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0
1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1
0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0
0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0
0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0
0,0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0,0
0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,0
0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0
0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0
1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1
0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0
0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0
};

...全文
103 点赞 收藏 10

10 条回复

。。。。。。。。。

1，将一步跳至的位置保存在一个动态数组reached[]里
2，从数组reached里依次取出位置点，跳下一步，判断新的位置是否在数组reached里，

3，终止条件，走到reached数组的结尾，也即没有新的位置加入了。

lzdoudou 2010-07-29

dyingswan 2010-07-29

technician00 2010-07-29

dyingswan 2010-07-29
[Quote=引用 4 楼 lightboat09 的回复:]

。。。。。。。。。

1，将一步跳至的位置保存在一个动态数组reached[]里
2，从数组reached里依次取出位置点，跳下一步，判断新的位置是否在数组reached里，

3，……
[/Quote]

20分钟就可以搞定

F(x,y)
{

for 所有没跳，能跳的地方{F(新x,新y,路径+xy)}
}

dyingswan 2010-07-29

[/Quote]

dyingswan 2010-07-29
[Quote=引用 4 楼 lightboat09 的回复:]

。。。。。。。。。

1，将一步跳至的位置保存在一个动态数组reached[]里
2，从数组reached里依次取出位置点，跳下一步，判断新的位置是否在数组reached里，

3，……
[/Quote]

3.2w+