- Sub pey_t()
- Dim ar, k0, br, jg
- k0 = 5 ''参数1
- ar = [b1].Resize(k0, k0)
-
- ReDim br(1 To k0, 0 To k0)
- For i = 1 To k0
- For j = 1 To k0
- If ar(i, j) = "" Then
- br(i, 0) = br(i, 0) + 1
- br(i, br(i, 0)) = j
- End If
- Next
- Next
-
- ReDim jg(1 To k0, 0 To 1)
- i = 1: t = 1 ''i=行号
- Do
- If i = 0 Then MsgBox "无解": Exit Sub
- If i > k0 Then Exit Do
- For j = jg(i, 0) + 1 To br(i, 0)
- If jg(br(i, j), 1) = 0 Then
- jg(br(i, j), 1) = 1
- jg(i, 0) = j
- t = 1
- Exit For
- End If
- Next
-
- If j > br(i, 0) Then
- t = -1
- jg(i, 0) = 0
- temp = br(i - 1, jg(i - 1, 0))
- jg(temp, 1) = 0
- End If
- i = i + t
- Loop
-
- For i = 1 To k0
- jg(i, 0) = br(i, jg(i, 0))
- Next
- [a1].Resize(k0, 1) = jg
- End Sub
复制代码
|