const n = 10;
var a: array [1..N] of real;
i, k: integer;
s: real;
begin
randomize;
for i:=1 to n do
a[i]:= random(10000, 50000);
write(a[i]:8:2,' ');
end;
writeln;
s:=0;
for i:=1 to n do s:=s+a[i];
s:=s/n;
writeln('ср.=',s:8:2);
k:=0;
if a[i]<s then a[i]:=a[i]*1.1
else if a[i]>s then k:=k+1;
writeln('k=',k);
for i:=1 to n do write(a[i]:8:2,' ');
end.
Пример:
34973.00 16546.00 13691.00 41315.00 24650.00 44459.00 18117.00 37906.00 19255.00 17842.00
ср.=26875.40
k=4
34973.00 18200.60 15060.10 41315.00 27115.00 44459.00 19928.70 37906.00 21180.50 19626.20
const N = 100;
median: real;
sum: real;
count_more, i: integer;
for i:= 1 to N do a[i]:= random(1, 1000);
sum:= 0;
for i:= 1 to N do sum:= sum + a[i];
median:= sum / N;
count_more:= 0;
for i:= 1 to N do begin
if a[i] > median then inc(count_more)
else a[i]:= a[i] * 1.1;
write(count_more);
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
const n = 10;
var a: array [1..N] of real;
i, k: integer;
s: real;
begin
randomize;
for i:=1 to n do
begin
a[i]:= random(10000, 50000);
write(a[i]:8:2,' ');
end;
writeln;
s:=0;
for i:=1 to n do s:=s+a[i];
s:=s/n;
writeln('ср.=',s:8:2);
k:=0;
for i:=1 to n do
if a[i]<s then a[i]:=a[i]*1.1
else if a[i]>s then k:=k+1;
writeln('k=',k);
for i:=1 to n do write(a[i]:8:2,' ');
writeln;
end.
Пример:
34973.00 16546.00 13691.00 41315.00 24650.00 44459.00 18117.00 37906.00 19255.00 17842.00
ср.=26875.40
k=4
34973.00 18200.60 15060.10 41315.00 27115.00 44459.00 19928.70 37906.00 21180.50 19626.20
Verified answer
const N = 100;
var a: array [1..N] of real;
median: real;
sum: real;
count_more, i: integer;
begin
randomize;
for i:= 1 to N do a[i]:= random(1, 1000);
sum:= 0;
for i:= 1 to N do sum:= sum + a[i];
median:= sum / N;
count_more:= 0;
for i:= 1 to N do begin
if a[i] > median then inc(count_more)
else a[i]:= a[i] * 1.1;
end;
write(count_more);
end.