int x = -5, y = -6;
do
{
Console.WriteLine($"x = {x}");
if (x > -2)
{
Console.WriteLine($"Add ++x to y({y})");
y += ++x;
}
else
{
Console.WriteLine($"Substract x from y({y})");
y -= x;
}
Console.WriteLine($"y = {y}");
Console.WriteLine();
} while (x++ < 3);
Console.WriteLine(y);
Lista kroków:
x = -5
Substract x from y(-6)
y = -1
x = -4
Substract x from y(-1)
y = 3
x = -3
Substract x from y(3)
y = 6
x = -2
Substract x from y(6)
y = 8
x = -1
Add ++x to y(8)
y = 8
x = 1
Add ++x to y(8)
y = 10
x = 3
Add ++x to y(10)
y = 14
14
a jeżeli chodzi o "++x"
https://stackoverflow.com/questions/8573190/pre-post-increment-in-c-sharp