program aa;
var n,m,p,q,i,j:longint;
map:array[-2..20,-2..20] of boolean;
f:array[0..20,0..20] of longint;
begin
read(n,m);
read(p,q);
fillchar(map,sizeof(map),false);
fillchar(f,sizeof(f),0);
map[p,q]:=true;
map[p-1,q-2]:=true;
map[p-1,q+2]:=true;
map[p+1,q-2]:=true;
map[p+1,q+2]:=true;
map[p-2,q-1]:=true;
map[p-2,q+1]:=true;
map[p+2,q-1]:=true;
map[p+2,q+1]:=true;
for i:=0 to n do
for j:=0 to n do
begin
if map[i,j]=true then f[i,j]:=0
else begin
if (i=0) and (j=0) then f[i,j]:=1 ;
if (i=0) and (j<>0) then f[i,j]:=f[i,j-1];
if (i<>0) and (j=0) then f[i,j]:=f[i-1,j];
if (i<>0) and (j<>0) then f[i,j]:=f[i-1,j]+f[i,j-1];
end;
end;
writeln(f[n,m]);
end.
n<=25,m<=25,map下标小了;
循环处有问题, for i:=0 to n do
for j:=0 to n (m) do.
你前面都对的,后面有些麻烦:
e[0,-1]:=1;
for i:=0 to a do
for j:=0 to b do
if f[i,j]=false then e[i,j]:=e[i-1,j]+e[i,j-1];
writeln(e[a,b]);
改下吧~亲~