c++程序设计题:题目是Knight Moves 请高手帮忙,非常感谢!

[复制链接]
查看11 | 回复1 | 2019-4-21 23:52:50 | 显示全部楼层 |阅读模式
Description
Background
Mr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move knights from one position to another so fast. Can you beat him?
The Problem
Your task is to write a program to calculate the minimum number of moves needed for a knight to reach one point from another, so that you have the chance to be faster than Somurolov.
For people not familiar with chess, the possible knight moves are shown in Figure 1.
Input
The input begins with the number n of scenarios on a single line by itself.
Next follow n scenarios. Each scenario consists of three lines containing integer numbers. The first line specifies the length l of a side of the chess board (4 #includeusing namespace std;int n,m,depe[10][2]={{1,2},{2,1},{2,-1},{1,-2},{-1,-2},{-2,-1},{-2,1},{-1,2}};int starx,stary,endx,endy,book[310][310],line[4][900000];void bfss(int num,int sum){
if(num>sum) return;
int x=line[1][num];
int y=line[2][num];
if(x==endx&&y==endy){
printf("%d\n"
回复

使用道具 举报

千问 | 2019-4-21 23:52:50 | 显示全部楼层
太复杂了!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行