Создать программу на языке vba в excel : ввести массив а (n). найти сумму элементов массива. каждый элементов массива увеличить на сумму. вывести полученный массив.
Sub m1() Cells.Clear Dim n As Integer, i As Integer, s As Integer n = InputBox("n = ") Cells(1, 1).Value = "n = " + Str(n) ReDim a(1 To n) For i = 1 To n a(i) = InputBox("a(" + Str(i) + ")") Next i Cells(2, 1).Value = "Исходный массив" Range(Cells(3, 1), Cells(3, n)).Value = a s = 0 For i = 1 To n s = s + a(i) Next i Cells(4, 1).Value = "s = " + Str(s) Cells(5, 1).Value = "Полученный массив" For i = 1 To n a(i) = a(i) + s Next i Range(Cells(6, 1), Cells(6, n)).Value = a End Sub
Cells.Clear
Dim n As Integer, i As Integer, s As Integer
n = InputBox("n = ")
Cells(1, 1).Value = "n = " + Str(n)
ReDim a(1 To n)
For i = 1 To n
a(i) = InputBox("a(" + Str(i) + ")")
Next i
Cells(2, 1).Value = "Исходный массив"
Range(Cells(3, 1), Cells(3, n)).Value = a
s = 0
For i = 1 To n
s = s + a(i)
Next i
Cells(4, 1).Value = "s = " + Str(s)
Cells(5, 1).Value = "Полученный массив"
For i = 1 To n
a(i) = a(i) + s
Next i
Range(Cells(6, 1), Cells(6, n)).Value = a
End Sub