const n=21;
var a:array[1..n] of integer;
sr:array[1..3] of real;
k,s,i,j:integer;
begin
randomize;
for i:=1 to n do
a[i]:=random(11);
write(a[i],' ');
end;
writeln;
k:=n div 3;
for j:=0 to 2 do
s:=0;
for i:=1 to k do s:=s+a[j*k+i];
sr[j+1]:=s/k;
for j:=1 to 3 do write(sr[j]:4:2,' ');
end.
Пример:
3 5 9 10 10 7 7 3 2 10 3 6 5 10 1 7 8 6 9 5 6
7.29 5.57 6.00
const n=21;
var a:array[1..n] of integer;
sr:array[1..3] of real;
k,s,i,j:integer;
begin
randomize;
for i:=1 to n do
begin
a[i]:=random(11);
write(a[i],' ');
end;
writeln;
k:=n div 3;
for j:=0 to 2 do
begin
s:=0;
for i:=1 to k do s:=s+a[j*k+i];
sr[j+1]:=s/k;
end;
for j:=1 to 3 do write(sr[j]:4:2,' ');
end.
Пример:
3 5 9 10 10 7 7 3 2 10 3 6 5 10 1 7 8 6 9 5 6
7.29 5.57 6.00