(注:题目里有图片,不方便复制,这里只粘贴一个错误的代码)
(ps:这条代码有201错误,请读者回帖帮博主找错,谢谢)。
var
f:array[-1..10000,-1..10000]of boolean;
i,j,k,l:longint; //l记录向上向下向左向右,i、j为指针。
m,n,x,y,z:longint;
{//隐藏了读入读出
Procedure openn;
begin
assign(input,'calc.in'); assign(output,'calc.out');
reset(input); rewrite(output);
end;
Procedure closee;
begin
close(input); close(output);
end;
}
BEGIN
readln(n,m,x,y,z);
fillchar(f,sizeof(f),false);
for i:=0 to n do
for j:=0 to m do
f[i,j]:=true;//初始化数组
i:=0; j:=0; l:=1;
k:=-1;
repeat
if (l mod 4=1) then
begin
while f[i,j]=true do
begin
f[i,j]:=false;
if((i=y)and(j=x))or(k<>-1)then inc(k);
if k=z then break;
inc(j);
end;
inc(l);
dec(j);
end; //向右
if (l mod 4=2)then
begin
while f[i,j]=true do
begin
f[i,j]:=false;
if((i=y)and(j=x))or(k<>-1)then inc(k);
if k=z then break;
inc(i);
end;
inc(l);
dec(i);
end; //向下
if (l mod 4=3)then
begin
while f[i,j]=true do
begin
f[i,j]:=false;
if((i=y)and(j=x))or(k<>-1)then inc(k);
if k=z then break;
dec(j);
end;
inc(l);
inc(j);
end; //向左
if (l mod 4=0)then
begin
while f[i,j]=true do
begin
f[i,j]:=false;
if((i=y)and(j=x))or(k<>-1)then inc(k);
if k=z then break;
dec(i);
end;
l:=1;
inc(i);
end; //向上
until k=z;
writeln(i,' ',j);
END.