jackwtsjack 2008-07-30 07:15:00
点我顶贴
收藏
删除
这是我的程序
program no223(input,output);
const x:array[1..8]of integer=(1,1,2,2,-1,-1,-2,-2);
y:array[1..8]of integer=(2,-2,1,-1,2,-2,1,-1);
var i,j,m,n,p,q,step:longint;
s,t:array[1..10000000,0..100]of longint;
procedure tui(k,step:integer);
var i,j,a:integer;
begin
for i:=1 to 8 do
for j:=1 to k do
begin
a:=(j-1)*8+i;
s[a,step]:=s[j,step-1]+x[i];
t[a,step]:=t[j,step-1]+y[i];
if (s[a,step]=p)and(q=t[a,step]) then
begin writeln(step); exit;end ;
end;
if step>0 then begin
step:=step+1;
tui(k*8,step);
end;
begin
readln(m,n,p,q);
s[1,0]:=m;
t[1,0]:=n;
tui(1,1);
end.
那位高人帮我解释一下