const type tVec array of real tMas array of tVec tCalcFunc function tV

 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const
m=2; n=5;
type
tVec=array [1..n] of real;
tMas=array [1..m] of tVec;
tCalcFunc=function (v: tVec; m: integer): real;
procedure LessCalc(var res: real; v: tVec; m: integer; action: tCalcFunc);
var
i, d: integer;
t: real;
done: boolean;
begin
d:=n div 2;
while d>0 do begin
repeat
done:=true;
for i:=1 to n-d do
if v[i]>v[i+d] then begin
t:=v[i]; v[i]:=v[i+d]; v[i+d]:=t; done:=false;
end;
until done;
d:=d div 2;
end;
res:=action(v,m);
end;
function Sum1(v: tVec; m: integer): real;
var r: real;
begin
r:=0; for m:=m downto 1 do r:=r+v[m];
Sum1:=r;
end;
function Sum2(v: tVec; m: integer): real;
var r: real;
begin
r:=0; for m:=m downto 1 do r:=r+sqr(v[m]);
Sum2:=r;
end;
var
a: tMas;
r: real;
i, j: integer;
begin
begin
WriteLn('введите элементы массива:');
for i:=1 to m do
for j:=1 to n do
readln(A[i,j]);
Write(a[i,j]:6:0);
LessCalc(r,a[i],3,Sum2); WriteLn('|',r:6:0);
end;
end.