begin
//1 вариант
Range(-3, 11).Sum.Println;
//2 вариант
Range(-3, 11).Aggregate(0, (Sum, x)-> Sum + x).Println;
//3 вариант
var Sum := 0;
foreach var x in Range(-3, 11) do
Sum += x;
Sum.Println;
//4 вариант
Sum := 0;
for var i := -3 to 11 do
Sum += i;
//5 вариант
var j := -3;
while j <= 11 do
Sum += j;
j += 1
end;
//6 вариант
j := -3;
repeat
j += 1;
until j > 11;
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
begin
//1 вариант
Range(-3, 11).Sum.Println;
//2 вариант
Range(-3, 11).Aggregate(0, (Sum, x)-> Sum + x).Println;
//3 вариант
var Sum := 0;
foreach var x in Range(-3, 11) do
Sum += x;
Sum.Println;
//4 вариант
Sum := 0;
for var i := -3 to 11 do
Sum += i;
Sum.Println;
//5 вариант
Sum := 0;
var j := -3;
while j <= 11 do
begin
Sum += j;
j += 1
end;
Sum.Println;
//6 вариант
Sum := 0;
j := -3;
repeat
Sum += j;
j += 1;
until j > 11;
Sum.Println;
end.