[求助]我错在哪里了?
Function det(a() As Single) As SingleDim n, i, p, q As Integer
ReDim a(1 To n, 1 To n)
For i = 1 To n
If n = 2 Then
det = a(1, 1) * a(2, 2) - a(1, 2) * a(2, 1)
ElseIf n > 2 Then
ReDim b(1 To n - 1, 1 To n - 1) As Single
Dim p, q As Integer
If i = 1 Then
For p = 1 To n - 1
For q = 1 To n - 1
b(p, q) = a(p + 1, q)
Next q
Next p
ElseIf i = n Then
For p = 1 To n - 1
For q = 1 To n - 1
b(p, q) = a(p, q)
Next q
Next p
Else
For p = 1 To i - 1
For q = 1 To n - 1
b(p, q) = a(p, q)
Next q
Next p
For p = i + 1 To n
For q = 1 To n - 1
b(p - 1, q) = a(p, q)
Next q
Next p
End If
If i + n Mod 2 = 0 Then
det = det + det(b()) * a(i, n)
Else
det = det - det(b()) * a(i, n)
End If
End If
Next i
End Function