a: 1 2 4 6 8 9 10 11 12 13 14 15 b: 3 5 7
a: 2 3 4 5 6 7 8 10 12 13 14 15 b: 1 9 11
a: 2 3 4 5 6 8 9 10 11 12 13 15 b: 1 7 14
from
DefDbl A-Z
Dim crlf$, tot, prod, a(15), b(15)
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
tot = 0: prod = 1
addOn 1
Text1.Text = Text1.Text & crlf & " done"
End Sub
Sub addOn(wh)
a(0) = a(0) + 1
a(a(0)) = wh: tot = tot + wh
If wh = 15 Then
If tot = prod Then
Text1.Text = Text1.Text & "a:"
For i = 1 To a(0)
Text1.Text = Text1.Text & Str(a(i))
Next
Text1.Text = Text1.Text & " b:"
For i = 1 To b(0)
Text1.Text = Text1.Text & Str(b(i))
Next
Text1.Text = Text1.Text & crlf
End If
Else
addOn wh + 1
End If
tot = tot - wh
a(0) = a(0) - 1
b(0) = b(0) + 1
b(b(0)) = wh: prod = prod * wh
If wh = 15 Then
If tot = prod Then
Text1.Text = Text1.Text & "a:"
For i = 1 To a(0)
Text1.Text = Text1.Text & Str(a(i))
Next
Text1.Text = Text1.Text & " b:"
For i = 1 To b(0)
Text1.Text = Text1.Text & Str(b(i))
Next
Text1.Text = Text1.Text & crlf
End If
Else
addOn wh + 1
End If
prod = prod / wh
b(0) = b(0) - 1
End Sub
|
Posted by Charlie
on 2015-08-18 12:02:45 |