const n=10; begin var a:=ArrRandom(n,-20,30); for var i:=0 to n-1 do if a[i] mod 8=0 then writeln(a[i],' - YES') else writeln(a[i],' - NO'); var p:=a.Where(x->x mod 8=0); if p.Count<>0 then writeln(p.Average) else writeln('Нет элементов, кратных 8'); end.
Пример: 25 - NO -14 - NO -11 - NO -3 - NO 5 - NO -15 - NO -16 - YES 25 - NO 15 - NO -15 - NO -16
Answers & Comments
Verified answer
// PascalABC.NET 3.3const n=10;
begin
var a:=ArrRandom(n,-20,30);
for var i:=0 to n-1 do
if a[i] mod 8=0 then writeln(a[i],' - YES')
else writeln(a[i],' - NO');
var p:=a.Where(x->x mod 8=0);
if p.Count<>0 then writeln(p.Average)
else writeln('Нет элементов, кратных 8');
end.
Пример:
25 - NO
-14 - NO
-11 - NO
-3 - NO
5 - NO
-15 - NO
-16 - YES
25 - NO
15 - NO
-15 - NO
-16