1)
var a, b: array [1..10] of integer; i, sum: integer;
begin
sum := 0;
for i := 1 to 10 do
b[i] := 0;
for i := 1 to 10 do
begin
read(a[i]);
if a[i] < 0 then
begin
sum := sum + 1;
b[i] := i;
end;
end;
writeln('Amount of negative numbers: ', sum);
for i := 1 to 10 do
if b[i] <> 0 then write(b[i], ' ');
end.
---------------------------
2)
var a: array [1..10] of integer; i: integer; flag: boolean;
begin
flag := false;
randomize;
for i := 1 to 10 do
begin
a[i] := random(10);
if a[i] = 5
then
flag := true;
end;
for i := 1 to 10 do
write(a[i], ' ');
if flag
then
writeln('YES')
else
writeln('NO');
end.
----------------------
3)
var a: array [1..10] of integer; i, ind, odd: integer;
begin
randomize;
ind := 0;
for i := 1 to 10 do
begin
a[i] := random(10);
if a[i] mod 2 <> 0
then
begin
ind := i;
odd := a[i];
end;
end;
for i := 1 to 10 do
write(a[i], ' ');
if ind <> 0
then
writeln(a[ind], ' ', ind)
else
writeln('Array has no odd elements');
end.
------------------------
4)
var a: array [1..10] of integer; i: integer;
begin
writeln;
randomize;
for i := 1 to 10 do
begin
a[i] := random(20);
write(a[i], ' ');
end;
writeln;
for i := 1 to 10 do
if (a[i] < 15) and(a[i] > 5)
then
write(a[i], ' ');
end.