Чему будет равно значение переменной b после выполнения фрагмента программы? b=0 a=-1 for i=1 to 3 x=a*i a=-a b=b+x next i
Answers & Comments
VitalinaG
1 шаг i = 1, b = 0, a = -1 x = -1 * 1 = -1 a = -(-1) = 1 b = 0 + (-1) = -1 2 шаг i = 2 b = -1 a = 1 x = 1*2 = 2 a = -1 b = -1 + 2 = 1 3 шаг i = 3 b = 1 a = -1 x = -1*3 = -3 a = 1 b = 1+(-3) = -2
Answers & Comments
i = 1, b = 0, a = -1
x = -1 * 1 = -1
a = -(-1) = 1
b = 0 + (-1) = -1
2 шаг
i = 2 b = -1 a = 1
x = 1*2 = 2
a = -1
b = -1 + 2 = 1
3 шаг
i = 3 b = 1 a = -1
x = -1*3 = -3
a = 1
b = 1+(-3) = -2