В одномерном массиве, состоящем из n веществ вычислить: 1. Количество элементов массива, меньших С. 2. Сумму целых частей элементов массива, расположенных после последнего отрицательного элемента.
Sub primer2() Const n = 10 Dim a(1 To n) As Double Dim i As Integer, c As Double, lastNeg As Integer, count As Integer, sumInt As Double c = 5 For i = 1 To n a(i) = (Rnd(10) * 20) - 5: Cells(i, 2) = a(i)
If a(i) < c Then count = count + 1 If a(i) < 0 Then lastNeg = i Next i For i = lastNeg + 1 To n sumInt = sumInt + Int(a(i)) Next i Cells(2, 4) = count Cells(2, 5) = sumInt
Sub primer2()
Const n = 10
Dim a(1 To n) As Double
Dim i As Integer, c As Double, lastNeg As Integer, count As Integer, sumInt As Double
c = 5
For i = 1 To n
a(i) = (Rnd(10) * 20) - 5: Cells(i, 2) = a(i)
If a(i) < c Then count = count + 1
If a(i) < 0 Then lastNeg = i
Next i
For i = lastNeg + 1 To n
sumInt = sumInt + Int(a(i))
Next i
Cells(2, 4) = count
Cells(2, 5) = sumInt
End Sub