Var ar:array[1..n] of integer; i,s:integer; begin randomize; writeln('Array:'); for i:=1 to n do begin ar[i]:=random(1,r); write(ar[i]:4); s:=s+ar[i]; end; writeln; writeln('5:'); for i:=1 to n do if ar[i]=5 then write(i:4); writeln; writeln('S=',s/n); end.
Answers & Comments
Verified answer
//Pascal ABC.NET v3.1 сборка 1172Const
n=5;
r=10;
Var
ar:array[1..n] of integer;
i,s:integer;
begin
randomize;
writeln('Array:');
for i:=1 to n do
begin
ar[i]:=random(1,r);
write(ar[i]:4);
s:=s+ar[i];
end;
writeln;
writeln('5:');
for i:=1 to n do
if ar[i]=5 then write(i:4);
writeln;
writeln('S=',s/n);
end.
Пример работы:
Array:
5 1 2 1 4
5:
1
S=2.6