В массиве В (12) случайных целых чисел (диапазон чисел [ -5..60] ) определить:а) сумму элементов б) количество элементов, которые меньше 7
Answers & Comments
fasalv
Var B: array [1..12] of integer; i, s, s_min: integer; begin writeln; randomize; s := 0; s_min := 0; for i := 1 to 12 do B[i] := random(65) - 5; for i := 1 to 12 do begin write(B[i], ' '); s := s + B[i]; if B[i] < 7 then s_min := s_min + 1; end; writeln(); writeln('Sum: ', s, ', amount of elemnts which lower than 7: ', s_min); end.
Answers & Comments
begin
writeln;
randomize;
s := 0;
s_min := 0;
for i := 1 to 12 do
B[i] := random(65) - 5;
for i := 1 to 12 do
begin
write(B[i], ' ');
s := s + B[i];
if B[i] < 7
then
s_min := s_min + 1;
end;
writeln();
writeln('Sum: ', s, ', amount of elemnts which lower than 7: ', s_min);
end.