PascalABC.NET 3.8
function SK(m: array of real; a, b: real) : (real, integer);
begin
var (s, k) := (0.0, 0);
foreach var d in m do
if d.Between(a, b) then
s += d;
Inc(k)
end;
Result := (s, k)
var n := ReadInteger('n=');
var mA := ReadArrReal('Массив А:', n);
var (a, b) := ReadInteger2('Введите a и b:');
var (s1, k1) := SK(mA, a, b);
Println('S1 =', s1, ' k1 =', k1);
n := ReadInteger('m=');
var mB := ReadArrReal('Массив B:', n);
(a, b) := ReadInteger2('Введите c и d:');
var (s2, k2) := SK(mB, a, b);
Println('S2 =', s2, ' k2 =', k2);
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
PascalABC.NET 3.8
function SK(m: array of real; a, b: real) : (real, integer);
begin
var (s, k) := (0.0, 0);
foreach var d in m do
if d.Between(a, b) then
begin
s += d;
Inc(k)
end;
Result := (s, k)
end;
begin
var n := ReadInteger('n=');
var mA := ReadArrReal('Массив А:', n);
var (a, b) := ReadInteger2('Введите a и b:');
var (s1, k1) := SK(mA, a, b);
Println('S1 =', s1, ' k1 =', k1);
n := ReadInteger('m=');
var mB := ReadArrReal('Массив B:', n);
(a, b) := ReadInteger2('Введите c и d:');
var (s2, k2) := SK(mB, a, b);
Println('S2 =', s2, ' k2 =', k2);
end.