Программирование матричных операций - VB (170578)

Формулировка задачи:

Помогите ,пожалуйста, второе и третье задание не работает,ошибку выдает, в цикле For..Next
Option Explicit
Dim A(1 To 100, 1 To 100) As Double
Dim i As Integer, j As Integer, n As Integer, z As Integer, y As Integer
Dim Max As Double, X(1 To 100) As Double
 
Private Sub Command1_Click()
Picture1.Cls
n = Val(Text1.Text)
For i = 1 To n
For j = 1 To n
 A(i, j) = ((2 * i + 3 * j) ^ 2) / ((i + j + 5) ^ (1 / 3))
 Picture1.Print Format(A(i, j), "#0.##"),
 Next j
Picture1.Print '
Next i
Picture1.Print
End Sub
 
Private Sub Command2_Click()
            Command1_Click
For i = 1 To n
Max = Sqr(A(i, 1))
For j = 1 To n
If Max < Sqr(A(i, j)) Then Max = Sqr(A(i, j))
Next j
X(i) = Max / j
Picture1.Print Format(X(i), "#0.##")
Next i
End Sub
 
Private Sub Command3_Click()
            Command1_Click
For i = 1 To n - 1
For j = 1 To n - 1
If A(j + 1, j + 1) > A(j, j) Then
z = A(j + 1, j + 1): A(j + 1, j + 1) = A(j, j): A(j, j) = z
Next j
Next i
For i = 1 To n
For j = 1 To n
Picture1.Print Format(A(i, j), "#0.##")
Next j
R$ = R$ + Chr(13) + Chr(10)
Next i
End Sub
 
Private Sub Command4_Click()
            Command1_Click
y = 0
For i = 1 To n - 2 Step 2
y = y + X(i) * X(i + 2)
Next i
Picture1.Print Format(y, "#0.##")
End Sub
 
Private Sub Form_Load()
    HScroll1.Max = Val(Picture1.Height)
    VScroll1.Max = Val(Picture1.Width)
    Picture1.AutoRedraw = True
End Sub
 
Private Sub HScroll1_Scroll()
    Picture1.Left = -HScroll1.Value
End Sub
 
Private Sub VScroll1_Scroll()
    Picture1.Top = -VScroll1.Value
End Sub

Код к задаче: «Программирование матричных операций - VB (170578)»

textual
Option Explicit
Dim A(1 To 100, 1 To 100) As Double
Dim i As Integer, j As Integer, n As Integer, z As Double, y As Double
Dim Max As Double, X(1 To 100) As Double
 
Private Sub Command1_Click()
    Call Matrix
End Sub
 
 Private Sub Command2_Click()
    Call Matrix
    Call MaxValueSqr
End Sub
 
Private Sub Command3_Click()
    Call Matrix
    Call RevDiagMatrix
End Sub
 
 Private Sub Command4_Click()
    Call Matrix
    Call MaxValueSqr
    Call SumX
End Sub
Sub Matrix()
 Picture1.Cls
 n = Val(Text1.Text)
    For i = 1 To n
           For j = 1 To n
                  A(i, j) = ((2 * i + 3 * j) ^ 2) / ((i + j + 5) ^ (1 / 3))
                  Picture1.Print Round(A(i, j), 2) & vbTab;
           Next j
           Picture1.Print '
     Next i
     Picture1.Print
 End Sub
 
Private Sub MaxValueSqr()
Dim k As Single
    For i = 1 To n
         Max = Sqr(A(i, 1))
         k = 1
         For j = 1 To n
               If Max < Sqr(A(i, j)) Then Max = Sqr(A(i, j)): k = j
         Next j
         X(i) = Max / k
         Picture1.Print Round(X(i), 2) & vbTab
    Next i
End Sub
 
Private Sub RevDiagMatrix()
    Call Matrix
    For i = 1 To n - 1
       For j = 1 To n - 1
           If A(j + 1, j + 1) > A(j, j) Then
               z = A(j + 1, j + 1)
               A(j + 1, j + 1) = A(j, j)
               A(j, j) = z
           End If
       Next j
    Next i
    For i = 1 To n
         For j = 1 To n
              Picture1.Print Round(A(i, j), 2) & vbTab;
         Next j
         Picture1.Print
    Next i
End Sub
 
Private Sub SumX()
    Picture1.Print vbCrLf
    y = 0
    For i = 1 To n - 2 Step 2
           y = y + X(i) * X(i + 2)
    Next i
    Picture1.Print Format(y, "#0.##")
End Sub
 
Private Sub Form_Load()
    HScroll1.Max = Val(Picture1.Height)
    VScroll1.Max = Val(Picture1.Width)
    Picture1.AutoRedraw = True
End Sub
 
Private Sub HScroll1_Scroll()
    Picture1.Left = -HScroll1.Value
End Sub
 
Private Sub VScroll1_Scroll()
    Picture1.Top = -VScroll1.Value
End Sub

9   голосов, оценка 3.222 из 5


СОХРАНИТЬ ССЫЛКУ