
Ввод и работа с массивами.pptx
- Количество слайдов: 3
Public Sub prim 1() Dim A(), B(), C() n = Val(Input. Box("Введите количество элементов в массиве")) ng = Val(Input. Box("Введите нижнюю границу диапазона")) vg = Val(Input. Box("Введите верхнюю границу диапазона")) Re. Dim A(n), B(n), C(n) Randomize For i = 1 To n a(i) = Int(ng + Rnd * (vg - ng)) b(i) = Int(ng + Rnd * (vg - ng)) Cells(i, 3) = a(i) Cells(i, 4) = b(i) Next i For i = 1 To n If Cells(i, 3) = 0 And Cells(i, 4) = 0 Then Cells(i, 6) = 0 Else. If Cells(i, 3) > 0 And Cells(i, 4) > 0 Then Cells(i, 6) = Cells(i, 3) + Cells(i, 4) Else. If Cells(i, 3) < 0 And Cells(i, 4) < 0 Then Cells(i, 6) = Cells(i, 3) * Cells(i, 4) Else Cells(i, 6) = 1 End If Next i End Sub
Public Sub prim 2() Dim A(), B(), C() n = Val(Input. Box("Введите количество элементов в массивах")) ng = Val(Input. Box("Введите нижнюю границу диапазона")) vg = Val(Input. Box("Введите верхнюю границу диапазона")) Re. Dim A(n), B(n), C(n) Randomize For i = 1 To n a(i) = Int(ng + Rnd * (vg - ng)) b(i) = Int(ng + Rnd * (vg - ng)) Cells(i, 3) = a(i) Cells(i, 4) = b(i) Next i For i = 1 To n If a(i) = 0 And b(i) = 0 Then c(i) = 0 Else. If a(i) > 0 And b(i) > 0 Then c(i) = a(i) + b(i) Else. If a(i) < 0 And b(i) < 0 Then c(i) = a(i) * b(i) Else c(i) = 1 End If Next i End Sub
Public Sub prim 3() Dim A(), B(), C() n = Val(Input. Box("Введите количество элементов в массивах")) ng = Val(Input. Box("Введите нижнюю границу диапазона")) vg = Val(Input. Box("Введите верхнюю границу диапазона")) Re. Dim A(n), B(n), C(n) Randomize For i = 1 To n a(i) = Int(ng + Rnd * (vg - ng)) b(i) = Int(ng + Rnd * (vg - ng)) Cells(i, 3) = a(i) Cells(i, 4) = b(i) Next i For i = 1 To n If a(i) = 0 And b(i) = 0 Then c(i) = 0 Cells(i, 6) = c(i) Else. If a(i) > 0 And b(i) > 0 Then c(i) = a(i) + b(i) Cells(i, 6) = c(i) Else. If a(i) < 0 And b(i) < 0 Then c(i) = a(i) * b(i) Cells(i, 6) = c(i) Else c(i) = 1 Cells(i, 6) = c(i) End If Next i End Sub
Ввод и работа с массивами.pptx