function ReadWhileSum(cond: integer->boolean): sequence of integer;
begin
var s := 0;
while True do
var x := ReadInteger();
s += x;
if not cond(s) then break;
yield x;
end;
Println('Сред. арифм. =',ReadWhileSum(sum -> sum < 150)
.Where(t->t.IsEven).Average);
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
PascalABC.NET 3.4.2, сборка 1814 от 02.10.2018
function ReadWhileSum(cond: integer->boolean): sequence of integer;
begin
var s := 0;
while True do
begin
var x := ReadInteger();
s += x;
if not cond(s) then break;
yield x;
end;
end;
begin
Println('Сред. арифм. =',ReadWhileSum(sum -> sum < 150)
.Where(t->t.IsEven).Average);
end.