Program Rome type point record integer end var arr array of point midd

 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
27
28
29
30
31
32
33
34
35
Program Rome;
type point = record
x, y: integer;
end;
var arr: array of point;
middle: point;
n: integer;
function calculateLength(point1, point2, middle: point): integer;
begin
calculateLength := abs(point1.x - middle.x) + abs(point1.y - point2.y) + abs(point2.x - middle.x);
end;
Begin
n := 5;
setLength(arr, n);
arr[0].x := 1; arr[0].y := 2;
arr[1].x := 2; arr[1].y := 1;
arr[2].x := 3; arr[2].y := 5;
arr[3].x := 4; arr[3].y := 4;
arr[4].x := 6; arr[4].y := 2;
//findMiddle return arr2
middle := arr[2];
for var i := 0 to n - 1 do begin
for var j := 0 to n - 1 do begin
if(i <> j) then begin
writeln(i + 1, ' - ', j + 1, ' = ', calculateLength(arr[i], arr[j], middle));
end;
end;
end;
var temp: integer;
end.