const nx=20;
var r:array[1..nx] of integer;
var j:real; n,i,sum,k:integer;
begin
randomize;
write('Введите n');
readln(n);
for i:= 1 to n do begin
r[i]:= random(15);
if ((i mod 4 = 0) and (r[i] < 5 )) then begin
sum:= r[i]+sum;
k:=k+1;
end;
write(r[i]:4);
writeln;
writeln('sum =',sum:3,' k =',k);
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
const nx=20;
var r:array[1..nx] of integer;
var j:real; n,i,sum,k:integer;
begin
randomize;
write('Введите n');
readln(n);
for i:= 1 to n do begin
r[i]:= random(15);
if ((i mod 4 = 0) and (r[i] < 5 )) then begin
sum:= r[i]+sum;
k:=k+1;
end;
write(r[i]:4);
end;
writeln;
writeln('sum =',sum:3,' k =',k);
end.