Sub num1()
s = 0
n = CInt(InputBox("N ="))
Range(Cells(1, 1), Cells(2 * (n + 2), n + 2)).Clear
ReDim A(n - 1)
ReDim B(n - 1)
k = 1
Cells(k, 1).Value = "A"
Cells(k + 2, 1).Value = "B"
k = k + 1
m = -1
For i = LBound(A, 1) To UBound(A, 1)
A(i) = Round(Rnd * 10) - 5
Cells(k, 1 + i).Value = A(i)
If A(i) = 0 Then
m = m + 1
B(m) = i
Cells(k + 2, m + 1).Value = B(m)
End If
Next
End Sub
Sub num2()
n = 16
ReDim A(n, n), C(n, n), E(n, n)
Range(Cells(1, 1), Cells(2 * (n + 2), n + 2)).Clear
k = 1
Cells(k, 1).Value = "Init"
k = k + 1
Cells(k + n + 1, 1).Value = "Result"
For i = 0 To n
For j = 0 To n
A(i, j) = Round(Rnd * 10)
Cells(k + i, j + 1).Value = A(i, j)
If i = j Then E(i, j) = 1 Else E(i, j) = 0
C(i, j) = 0
For r = 0 To n
C(i, j) = C(i, j) + A(i, r) * A(r, j)
Next
x = 6 * (C(i, j) + E(i, j))
Cells(k + n + 2 + i, j + 1).Value = x
Next
Next
End Sub