PASCAL С клавиатуры вводится 30 чисел .Сколько среди них нулей .Найти среднее арифметическое из суммы чисел кратных 5-ти.
Answers & Comments
HiroX
Var nulls, average, n, s: integer; var arr[0..29]: array of integer; begin for var i := 0 to 29 do read(arr[i]); for var i := 0 to 29 do begin if arr[i] = 0 then nulls++; if arr[i] mod 5 == 0 then begin s += arr[i]; n++; end; end; average = s / n; writeln("0s = ", nulls); writeln("Average = ", average); end.
Answers & Comments
var arr[0..29]: array of integer;
begin
for var i := 0 to 29 do read(arr[i]);
for var i := 0 to 29 do
begin
if arr[i] = 0 then nulls++;
if arr[i] mod 5 == 0 then
begin
s += arr[i];
n++;
end;
end;
average = s / n;
writeln("0s = ", nulls);
writeln("Average = ", average);
end.