想了半天,脑细胞不够用了,就想到这个方法,不知道怎么简化,但是一定能一步得到结果。
注意:vba方法,使用前请确定启用宏。
Sub tst()
Dim p%, a%, b%, c%, d%, i%
i = 1
For p = 1000 To 9999
a = Mid(p, 1, 1)
b = Mid(p, 2, 1)
c = Mid(p, 3, 1)
d = Mid(p, 4, 1)
If a 0 And b 0 And c 0 And d 0 And a + b + c + d = 10 And a * b * c * d = 24 Then
Cells(i, 1) = p
i = i + 1
End If
Next
End Sub