1)
const n=16;
var a:array[1..n] of integer;
i,k:integer;
begin
Randomize;
writeln('Массив A:');
for i:=1 to n do
begin
a[i]:=random(41)-20;
write(a[i]:4);
end;
writeln;
k:=0;
for i:=1 to n do
if a[i]<0 then k:=k+1;<br>writeln('k = ',k);
end.
Пример:
Массив A:
-14 -7 -20 -3 12 9 -5 -4 7 11 -14 7 6 13 10 12
k = 7
2)
begin
var a:=ArrRandom(16,-20,20); a.Println;
var k:=a.Where(x->(x<0)).Count;<br> writeln('k = ',k);
end.
Пример:
7 9 -12 12 -7 -14 -16 15 18 -8 -5 -11 1 19 11 5
k = 7