матричные операции - VB (170576)

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

Помогите,пожалуйста, дана матрица ,нужно вычислить сумму X1*X3+X3*X5+X5*X7.. где X1- сумма элементов первой строки ,X3-сумма элементов третей строки и тд На Команд 4 ошибку выдает
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, k As Integer, S 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 j = 1 To n
Max = Sqr(A(1, j))
For i = 2 To n
If Max < Sqr(A(i, j)) Then Max = Sqr(A(i, j))
Next i
X(i) = Max
Picture1.Print Format(X(i), "##0.##")
Next j
End Sub
 
Private Sub Command3_Click()
            Command1_Click
For j = 1 To n - 1
For k = 1 To n - 1
If A(k + 1, k + 1) > A(k, k) Then
z = A(k + 1, k + 1)
A(k + 1, k + 1) = A(k, k)
A(k, k) = z
End If
Next k
Next j
For j = 1 To n
For k = 1 To n
Picture1.Print Format(A(j, k), "##0.##"),
 Next k
Picture1.Print '
 Next j
End Sub
 
Private Sub Command4_Click()
            Command1_Click
For j = 1 To n
y = 0
For i = 1 To n
y = y + A(i, j)
Next i
X(i) = y
 S = 0
 For i = 1 To n - 2 Step 2
S = S + X(i) * X(i + 2)
Next i
Picture1.Print Format(S, "#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 (170576)»

textual
Private Sub Command1_Click()
n = 5: m = 1
ReDim a(n, m)
Randomize (Timer)
For i = 1 To n
  For j = 1 To m
    a(i, j) = Int(Rnd * 10)
    Print a(i, j); vbTab;
  Next j
  Print
Next i
Print s(a)
End Sub
 
Function s(m())
r = UBound(m, 1): c = UBound(m, 2)
s = 0
For i = 1 To r Step 2
  s3 = 0
  For j = 1 To c
     s3 = s3 + m(i, j)
  Next j
  If i > 1 Then s = s + s1 * s3
  s1 = s3
Next i
End Function

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


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