Пусть вводится n чисел с клавиатуры определить кол-во нечетных чисел в массиве и произведение отрицательных чисел (составить программу на бейсике) 98 !
Sub Calculate() Dim coll As Collection Dim i As Integer Dim sum As Double Dim negative As Integer Dim composition As Integer negative = 0 composition = 1 Set coll = New Collection sum = 0 n = CInt(InputBox("Введите количество чисел", "Ввод", "", 2000, 2000)) For i = 1 To n elmnt = CInt(InputBox(i & " число", "Ввод", "", 2000, 2000)) coll.Add elmnt sum = sum + elmnt Next i
For i = 1 To coll.Count If (coll.Item(i) < 0) Then negative = negative + 1 End If If (coll.Item(i) Mod 2 = 1) Then composition = composition * coll.Item(i) End If Next i MsgBox "Количество отрицательных = " & negative & vbCrLf & "Произведение нечетных = " & composition & vbCrLf, vbOKOnly, "Результаты" End Sub
Dim coll As Collection
Dim i As Integer
Dim sum As Double
Dim negative As Integer
Dim composition As Integer
negative = 0
composition = 1
Set coll = New Collection
sum = 0
n = CInt(InputBox("Введите количество чисел", "Ввод", "", 2000, 2000))
For i = 1 To n
elmnt = CInt(InputBox(i & " число", "Ввод", "", 2000, 2000))
coll.Add elmnt
sum = sum + elmnt
Next i
For i = 1 To coll.Count
If (coll.Item(i) < 0) Then
negative = negative + 1
End If
If (coll.Item(i) Mod 2 = 1) Then
composition = composition * coll.Item(i)
End If
Next i
MsgBox "Количество отрицательных = " & negative & vbCrLf & "Произведение нечетных = " & composition & vbCrLf, vbOKOnly, "Результаты"
End Sub