program t1;
var i,j,k,l,m,n,x,y,i1:longint;
a:array[1..10000,1..2] of longint;
procedure qsort(l,r:longint);
var i,j,x,t:longint;
begin
i:=l;
j:=r;
x:=a[(i+j) div 2,1];
repeat
while x>a[i,1] do i:=i+1;
while x if i<=j then
begin
t:=a[j,1];
a[j,1]:=a[i,1];
a[i,1]:=t;
t:=a[j,2];
a[j,2]:=a[i,2];
a[i,2]:=t;
i:=i+1;
j:=j-1;
end;
until i>j;
if i
begin
readln(n,i,j);
for x:=1 to n do
write('(',i,',',x,')');{同一行上格子的位置}
writeln;
for y:=1 to n do
write('(',y,',',j,')');{同列列上格子的位置}
writeln;
{左上到右下对角线上的格子的位置}
k:=1;
x:=i;
y:=j;
a[k,1]:=x; a[k,2]:=y;
while (x+1<=n) and (y+1<=n) do
begin
x:=x+1;
y:=y+1;
k:=k+1;
a[k,1]:=x;
a[k,2]:=y;
end;
x:=i;
y:=j;
while (x-1>=1) and (y-1>=1) do
begin
x:=x-1;
y:=y-1;
k:=k+1;
a[k,1]:=x;
a[k,2]:=y;
end;
qsort(1,k);
for i1:=1 to k do
write('(',a[i1,1],',',a[i1,2],')');
writeln;
{左下到右上对角线上的格子的位置}
k:=1;
x:=i;
y:=j;
a[k,1]:=x; a[k,2]:=y;
while (x+1<=n) and (y-1>=1) do
begin
x:=x+1;
y:=y-1;
k:=k+1;
a[k,1]:=x;
a[k,2]:=y;
end;
x:=i;
y:=j;
while (x-1>=1) and (y+1<=n) do
begin
x:=x-1;
y:=y+1;
k:=k+1;
a[k,1]:=x;
a[k,2]:=y;
end;
qsort(1,k);
for i1:=k downto 1 do
write('(',a[i1,1],',',a[i1,2],')');
writeln;
end.
望采纳
左上到右下从大到小枚举坐标差相等的
左下到右上从小到大枚举坐标和相等的~