Dim strr Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Line Input #1, strr strr = Right(strr, Len(strr) - InStr(strr, "{")) strr = Replace(strr, "}", "") strr = Replace(strr, " ", "") strr = Split(strr, ",") Call rr("", 0) Close #2 Close #1 End End Sub
Public Function rr(k As String, ByVal x As Integer) temp = "{" & k & "}" temp = Replace(temp, ",}", "}") Print #2, temp For i = x To UBound(strr) If InStr(k, strr(i)) = 0 Then Call rr(k & strr(i) & ",", i) Next
Dim a() As String Dim n As Integer Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, g Line Input #1, x g = Replace(g, "N=", "") x = LTrim(Replace(x, "A { ", "")) x = Replace(x, " } ", "") a = Split(x, ", ") n = Val(g) Print #2, "{ }" For i = 1 To n Call b("", 0, i) Next i Close #2 Close #1 End End Sub
Sub b(c, d, t) If Len(c) = t * 2 Then c = "{ " & c & " }" c = Replace(c, ", }", " }") Print #2, c Else For i = d To UBound(a) If InStr(c, a(i)) = 0 Then Call b(c & a(i) & ",", i + 1, t) Next i End If End Sub
Dim strr
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Line Input #1, strr
strr = Right(strr, Len(strr) - InStr(strr, "{"))
strr = Replace(strr, "}", "")
strr = Replace(strr, " ", "")
strr = Split(strr, ",")
Call rr("", 0)
Close #2
Close #1
End
End Sub
Public Function rr(k As String, ByVal x As Integer)
temp = "{" & k & "}"
temp = Replace(temp, ",}", "}")
Print #2, temp
For i = x To UBound(strr)
If InStr(k, strr(i)) = 0 Then Call rr(k & strr(i) & ",", i)
Next
End Function
Dim a() As String
回覆刪除Dim n As Integer
Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, g
Line Input #1, x
g = Replace(g, "N=", "")
x = LTrim(Replace(x, "A { ", ""))
x = Replace(x, " } ", "")
a = Split(x, ", ")
n = Val(g)
Print #2, "{ }"
For i = 1 To n
Call b("", 0, i)
Next i
Close #2
Close #1
End
End Sub
Sub b(c, d, t)
If Len(c) = t * 2 Then
c = "{ " & c & " }"
c = Replace(c, ", }", " }")
Print #2, c
Else
For i = d To UBound(a)
If InStr(c, a(i)) = 0 Then Call b(c & a(i) & ",", i + 1, t)
Next i
End If
End Sub
'in.txt
N=3, A { 1, 2, 3 }
'out.txt
{ }
{ 1 }
{ 2 }
{ 3 }
{ 1,2 }
{ 1,3 }
{ 2,3 }
{ 1,2,3 }