Page 171 - 4192
P. 171

Програмний код:
                Sub Maxi(X As Variant, n, max, k)
                max = -1E+38
                For i = 1 To n
                If X(i) > max Then max = X(i): k = i
                Next i
                End Sub
                Private Sub Command1_Click()
           Dim A(1 To 8), B(1 To 11), C(1 To 14) As Single
           Dim i, k1, k2, k3 As Integer
           Dim m1, m2, m3 As Single
           For i = 1 To 8
           A(i) = Val(InputBox("Введіть " + Str(i) + " елемент масиву A(8)
           ", i))
           Picture1.Print A(i); " ";
           Next i
           Call Maxi(A(), 8, m1, k1)
           For i = 1 To 11
           B(i) = Val(InputBox("Введіть " + Str(i) + " елемент масиву
           B(11) ", i))
           Picture2.Print B(i); " ";
           Next i
           Call Maxi(B(), 11, m2, k2)
           For i = 1 To 14
           C(i) = Val(InputBox("Введіть " + Str(i) + " елемент масиву
           C(14) ", i))
           Picture3.Print C(i); " ";
           Next i
           Call Maxi(C(), 14, m3, k3)
           Picture4.Print "max A(8)="; m1, "індекс="; k1
           Picture4.Print "max B(11)="; m2, "індекс="; k2
           Picture4.Print "max C(14)="; m3, "індекс="; k3
                End Sub


                                             170
   166   167   168   169   170   171   172   173   174   175   176