Var i,s,t,n:integer; a:array[1..100] of integer; begin write('Write size array: ');readln(n); for i:=1 to n do begin a[i]:=Random(150)-50; write(a[i]:4); end; s:=0; t:=0; for i:=1 to n do if (a[i]>=-2) and (a[i]<=10) then begin s:=s+a[i]; inc(t); end; writeln('Average: ',s/t:0:2); readln; end.
i,s,t,n:integer;
a:array[1..100] of integer;
begin
write('Write size array: ');readln(n);
for i:=1 to n do
begin
a[i]:=Random(150)-50;
write(a[i]:4);
end;
s:=0;
t:=0;
for i:=1 to n do
if (a[i]>=-2) and (a[i]<=10)
then begin s:=s+a[i]; inc(t); end;
writeln('Average: ',s/t:0:2);
readln;
end.