function array_distance dimension integer array of integer begin var i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function array_distance (dimension, n, m:integer): array [,] of integer;
begin
var i, j, i1, j1, count, count_row:integer;
var arr: array [,] of integer;
arr := new integer[dimension, dimension];
for i := 0 to n - 1 do begin
for j := 0 to m - 1 do begin
for i1 := 0 to n - 1 do begin
for j1 := 0 to m - 1 do begin
if(count_row = dimension) then begin
break;
end;
if(count < dimension) then begin
arr[count, count_row] := abs(i1 - i) + abs(j1 - j);
count := count + 1;
end;
if(count = dimension) then begin
count := 0;
count_row := count_row + 1;
end;
end;
end;
end;
end;
array_distance:=arr;
end;