Sub Q(ans As String, dot) If dot = 6 Then Print #2, Left(ans, Len(ans) - 1) Else For i = 0 To 9 If InStr(ans, s(i)) = 0 Then Call Q(ans & s(i) & ",", dot + 1) Next End If End Sub
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, N Y = Split(N, ",") For i = 0 To UBound(Y) X(i) = Y(i) z(i) = 0 Next i ans = 0 Call abc("", 0) Print #2, "共有" & ans & "組牌" Close #2 Close #1 End End Sub
Sub abc(ByVal A, ByVal B) If B = 6 Then Print #2, Right(A, Len(A) - 1) ans = ans + 1 Else For i = 0 To UBound(X) If NOre(X(i)) = fasle Then z(B) = X(i): Call abc(A & "," & X(i), B + 1) Next i End If End Sub
Function NOre(N) Dim re As Boolean re = False For i = 0 To 5 If z(i) = N Then re = True: NOre = True: Exit For Next i If re = False Then NOre = False End Function
Dim m(10) Private Sub Form_Load() Open App.Path & "\out.txt" For Output As #2 Open App.Path & "\in.txt" For Input As #1
For i = 0 To 9 Input #1, m(i) Next 'Call c("", m, 0) For i = 0 To 9 a = m(i) & a For ii = 0 To 9 If m(ii) <> m(i) Then a = m(ii) & a For iii = 0 To 9 If m(iii) <> m(i) And m(iii) <> m(ii) Then a = m(iii) & a For iiii = 0 To 9 If m(iiii) <> m(i) And m(iiii) <> m(ii) And m(iiii) <> m(iii) Then a = m(iiii) & a For iiiii = 0 To 9 If m(iiiii) <> m(i) And m(iiiii) <> m(ii) And m(iiiii) <> m(iii) And m(iiiii) <> m(iiii) Then a = m(iiiii) & a For iiiiii = 0 To 9 If m(iiiiii) <> m(i) And m(iiiiii) <> m(ii) And m(iiiiii) <> m(iii) And m(iiiiii) <> m(iiii) And m(iiiiii) <> m(iiiii) Then a = m(iiiiii) & a: Print #2, a, c = c + 1 Next Next Next Next Next Next Print #2, "共有 " & c & " 組牌" Close #1 Close #2 End Sub Sub c(a, b, j) If j = 6 Then j = 0 Print #2, a Else For i = 0 To UBound(b) If InStr(a, b(i)) = 0 Then j = j + 1: Call c(a & b(i) & ",", b, j) Next End If End Sub
Dim s(9)
回覆刪除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, s(0), s(1), s(2), s(3), s(4), s(5), s(6), s(7), s(8), s(9)
Call Q("", 0)
Close
Close
End
End Sub
Sub Q(ans As String, dot)
If dot = 6 Then
Print #2, Left(ans, Len(ans) - 1)
Else
For i = 0 To 9
If InStr(ans, s(i)) = 0 Then Call Q(ans & s(i) & ",", dot + 1)
Next
End If
End Sub
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, N
Y = Split(N, ",")
For i = 0 To UBound(Y)
X(i) = Y(i)
z(i) = 0
Next i
ans = 0
Call abc("", 0)
Print #2, "共有" & ans & "組牌"
Close #2
Close #1
End
End Sub
Sub abc(ByVal A, ByVal B)
If B = 6 Then
Print #2, Right(A, Len(A) - 1)
ans = ans + 1
Else
For i = 0 To UBound(X)
If NOre(X(i)) = fasle Then z(B) = X(i): Call abc(A & "," & X(i), B + 1)
Next i
End If
End Sub
Function NOre(N)
Dim re As Boolean
re = False
For i = 0 To 5
If z(i) = N Then re = True: NOre = True: Exit For
Next i
If re = False Then NOre = False
End Function
Dim m(10)
回覆刪除Private Sub Form_Load()
Open App.Path & "\out.txt" For Output As #2
Open App.Path & "\in.txt" For Input As #1
For i = 0 To 9
Input #1, m(i)
Next
'Call c("", m, 0)
For i = 0 To 9
a = m(i) & a
For ii = 0 To 9
If m(ii) <> m(i) Then a = m(ii) & a
For iii = 0 To 9
If m(iii) <> m(i) And m(iii) <> m(ii) Then a = m(iii) & a
For iiii = 0 To 9
If m(iiii) <> m(i) And m(iiii) <> m(ii) And m(iiii) <> m(iii) Then a = m(iiii) & a
For iiiii = 0 To 9
If m(iiiii) <> m(i) And m(iiiii) <> m(ii) And m(iiiii) <> m(iii) And m(iiiii) <> m(iiii) Then a = m(iiiii) & a
For iiiiii = 0 To 9
If m(iiiiii) <> m(i) And m(iiiiii) <> m(ii) And m(iiiiii) <> m(iii) And m(iiiiii) <> m(iiii) And m(iiiiii) <> m(iiiii) Then a = m(iiiiii) & a: Print #2, a, c = c + 1
Next
Next
Next
Next
Next
Next
Print #2, "共有 " & c & " 組牌"
Close #1
Close #2
End Sub
Sub c(a, b, j)
If j = 6 Then
j = 0
Print #2, a
Else
For i = 0 To UBound(b)
If InStr(a, b(i)) = 0 Then j = j + 1: Call c(a & b(i) & ",", b, j)
Next
End If
End Sub
arro:少了共幾組。
回覆刪除佑、緣尉:正確。
三人的程式,雖然以arro的程式最好,但是,0分。要小心看題目。