const n=30;
var a:array[1..n] of integer;
i,k:integer;
begin
randomize;
for i:=1 to n do
a[i]:=random(41)-10;
write(a[i]:4);
end;
writeln;
k:=0;
if a[i]<0 then k:=k+1;
writeln('k = ',k);
end.
Пример:
28 3 19 6 -3 0 3 26 8 10 27 -3 3 -1 20 -10 3 -4 2 20 -8 20 23 15 5 7 -5 -1 6 14
k = 8
const n=30;
var a:array[1..n] of integer;
i,k:integer;
begin
randomize;
for i:=1 to n do
begin
a[i]:=random(41)-10;
write(a[i]:4);
end;
writeln;
k:=0;
for i:=1 to n do
if a[i]<0 then k:=k+1;
writeln('k = ',k);
end.
Пример:
28 3 19 6 -3 0 3 26 8 10 27 -3 3 -1 20 -10 3 -4 2 20 -8 20 23 15 5 7 -5 -1 6 14
k = 8