В массиве А(20) случайных целых чисел (диапазон чисел [-10..30] ) определить количество нечетных чисел
Answers & Comments
fasalv
Var a: array [1..20] of integer; i, s: integer; begin randomize; s := 0; for i := 1 to 20 do a[i] := random(40) - 10; for i := 1 to 20 do begin write(a[i], ' '); if (a[i] + 10) mod 2 = 1 then s := s + 1; end; writeln(); writeln(s); end.
Answers & Comments
begin
randomize;
s := 0;
for i := 1 to 20 do
a[i] := random(40) - 10;
for i := 1 to 20 do
begin
write(a[i], ' ');
if (a[i] + 10) mod 2 = 1
then
s := s + 1;
end;
writeln();
writeln(s);
end.