var
s, i: integer;
a: array[1..6] of integer;
begin
Randomize;
s := 0;
for i := 1 to 6 do
a[i] := random(50);
write(a[i], ' ');
if (a[i] > 10) and (a[i] < 30) then s := s + a[i];
end;
writeln();
writeln('s = ', s)
end.
var a := ArrRandomInteger(6, 0, 50);
Writeln(a);
var s := a.Where(x -> (x > 10) and (x < 30)).Sum();
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
//в стиле старого паскаля
var
s, i: integer;
a: array[1..6] of integer;
begin
Randomize;
s := 0;
for i := 1 to 6 do
begin
a[i] := random(50);
write(a[i], ' ');
if (a[i] > 10) and (a[i] < 30) then s := s + a[i];
end;
writeln();
writeln('s = ', s)
end.
//PascalABC.NET версия 3.9 (2023-07-11)
begin
var a := ArrRandomInteger(6, 0, 50);
Writeln(a);
var s := a.Where(x -> (x > 10) and (x < 30)).Sum();
writeln('s = ', s)
end.