我有一个生成二维数组的代码,看起来像这样
0 0 0 0 0 34 41 43 45 0
0 0 0 0 25 30 35 42 44 0
0 0 0 14 20 26 31 36 40 0
0 0 1 8 15 21 27 32 37 0
0 0 0 2 9 16 22 28 33 0
0 0 0 0 3 10 17 23 29 0
0 0 0 0 0 4 11 18 24 0
0 0 0 0 0 0 5 12 19 0
0 0 0 0 0 0 0 6 13 0
0 0 0 0 0 0 0 0 7 0
生成数字的源代码部分是
j:=3;
for i:=4 to 10 do
begin
ms[i,j]:=wrk;
wrk:=wrk+1;
j:=j+1
end;
j:=4;
for i:=4 to 9 do
begin
ms[i,j]:=wrk;
wrk:=wrk+1;
j:=j+1
end;
j:=4;
for i:=3 to 8 do
begin
ms[i,j]:=wrk;
wrk:=wrk+1;
j:=j+1
end;
j:=5;
for i:=3 to 7 do
begin
ms[i,j]:=wrk;
wrk:=wrk+1;
j:=j+1
end;
j:=5;
for i:=2 to 6 do
begin
ms[i,j]:=wrk;
wrk:=wrk+1;
j:=j+1
end;
j:=6;
for i:=2 to 5 do
begin
ms[i,j]:=wrk;
wrk:=wrk+1;
j:=j+1
end;
j:=6;
for i:=1 to 4 do
begin
ms[i,j]:=wrk;
wrk:=wrk+1;
j:=j+1
end;
j:=7;
for i:=1 to 3 do
begin
ms[i,j]:=wrk;
wrk:=wrk+1;
j:=j+1
end;
j:=7;
for i:=1 to 2 do
begin
ms[i,j]:=wrk;
wrk:=wrk+1;
j:=j+1
end;
j:=8;
for i:=1 to 2 do
begin
ms[i,j]:=wrk;
wrk:=wrk+1;
j:=j+1
end;
j:=9;
for i:=1 to 1 do
begin
ms[i,j]:=wrk;
wrk:=wrk+1;
j:=j+1
end;
我需要优化代码并使其尽可能小并执行相同的功能。有没有办法做到这一点?