program First; var a : array[1..50] of byte; i, s : integer; n : real;
begin randomize; s := 0; for i:=1 to 50 do begin a[i] := random(100); s := s+a[i]; write(a[i], ' '); end; writeln; n:= s/50; writeln(n:10:4); end.
program Second; var a : array[1..50] of byte; i, s, n, s1, n1 : integer; f : real;
begin randomize; s:=0; s1:=0; n:=0; n1:=0; for i:=1 to 50 do begin a[i] := random(100); if a[i] < 50 then begin s:=s+a[i]; inc(s1); end else begin n:=n+a[i]; inc(n1); end; write (a[i]); end; writeln; f := s/s1; writeln('Меньше 50: ', f:10:4); f := n/n1; writeln('Больше 50: ', f:10:4); end.
Answers & Comments
program First;
var
a : array[1..50] of byte;
i, s : integer;
n : real;
begin
randomize;
s := 0;
for i:=1 to 50 do begin
a[i] := random(100);
s := s+a[i];
write(a[i], ' ');
end;
writeln;
n:= s/50;
writeln(n:10:4);
end.
program Second;
var
a : array[1..50] of byte;
i, s, n, s1, n1 : integer;
f : real;
begin
randomize;
s:=0; s1:=0;
n:=0; n1:=0;
for i:=1 to 50 do begin
a[i] := random(100);
if a[i] < 50 then
begin
s:=s+a[i];
inc(s1);
end
else
begin
n:=n+a[i];
inc(n1);
end;
write (a[i]);
end;
writeln;
f := s/s1;
writeln('Меньше 50: ', f:10:4);
f := n/n1;
writeln('Больше 50: ', f:10:4);
end.