CDN加速镜像 | 设为首页 | 加入收藏夹
当前位置: 首页 资源下载 源码下载 数值算法/人工智能 数据结构常用算法

文件名称:horse

  • 所属分类:
  • 标签属性:
  • 上传时间:
    2012-11-16
  • 文件大小:
    849.98kb
  • 已下载:
    0次
  • 提 供 者:
  • 相关连接:
  • 下载说明:
    别用迅雷下载,失败请重下,重下不扣分!

介绍说明--下载内容来自于网络,使用问题请自行百度

问题描述与实验目的

给定8*8方格棋盘,求棋盘上一只马从一个位置到达另一位置的最短路径长。

注意马是走“日”形的。

输入

输入有若干测试数据。

每组测试数据仅1行,每行上有2个方格pos1、pos2,之间用一个空格隔开,每格方格表示棋盘上的一个位置,该位置由表示列的1个字母(a-h)及表示行的一个数字(1-8)构成,如“d7”表示第4列第7行。

输出

对输入中每行上的2个方格pos1、pos2,输出马从位置pos1跳到pos2所需的最短路径长。如“a1==>a2: 3 moves”表示从位置a1跳到a2所需的最少步数是3。

注意:按输出样例所示格式输出,如“a1==>a2: 3 moves”中冒号后有一个空格,再跟着所需的最少步数。

实验结果

输入样例

a1 a2

a1 a3

a1 h8

g2 b8



输出样例

a1==>a2: 3 moves

a1==>a3: 2 moves

a1==>h8: 6 moves

g2==>b8: 5 moves

-Descr iption and purpose of the experiment

8* 8 grid for a given board, find the board a horse from one location to another location to reach the shortest path length.

Note that horse is to take the "day" shape.

Input

Enter a number of test data.

Only 1 line of each test data, each line has 2 squares pos1, pos2, separated by a space, each grid square, said a board position, the position of column 1 by the said letters ( ah), and that the line of a number (1-8) form, such as "d7" said the line 7 column 4.

Output

Each line in the input box on the two pos1, pos2, output horse to jump from position pos1 pos2 shortest path length required. Such as "a1 ==> a2: 3 moves" that jump from position a1 a2 minimum required number of steps is 3.

Note: The sample shown by the output format of the output, such as "a1 ==> a2: 3 moves" in a space after the colon, and then follow the required minimum number of steps.

Experimental results

Input sample

a1 a2

a1 a3

a1 h8

g2 b8



Sample Ou
(系统自动生成,下载前可以参看下载内容)

下载文件列表

horse/horse.dsw
horse/horse.ncb
horse/horse.plg
horse/horse.dsp
horse/horse.cpp
horse/Debug/vc60.idb
horse/Debug/vc60.pdb
horse/Debug/horse.pch
horse/Debug/horse.exe
horse/Debug/horse.pdb
horse/Debug/horse.obj
horse/Debug/horse.ilk
horse/horse.opt
horse/Debug
horse

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 搜珍网是交换下载平台,只提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。更多...
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或换浏览器;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.

相关评论

暂无评论内容.

发表评论

*快速评论: 推荐 一般 有密码 和说明不符 不是源码或资料 文件不全 不能解压 纯粹是垃圾
*内  容:
*验 证 码:
搜珍网 www.dssz.com