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, n For i = 1 To n List1.Clear: List2.Clear Line Input #1, X Y = Split(X) For j = 0 To UBound(Y) List1.AddItem Y(j) Next j
For j = 0 To (List1.ListCount - 2) For r = j + 1 To (List1.ListCount - 1) If List1.List(j) = List1.List(r) Then Call ABC(List1.List(j)) End If Next r Next j
For j = 0 To List1.ListCount - 1 If Left(List1.List(j), 1) <> "X" Then List2.AddItem List1.List(j) Next j
Print #2, List2.ListCount
Next i Close #2 Close #1 End End Sub
Sub ABC(A) For i = 0 To List1.ListCount - 1 If A = List1.List(i) Then List1.List(i) = "X" & List1.List(i) Next i 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
Input #1, n
For i = 1 To n
List1.Clear: List2.Clear
Line Input #1, X
Y = Split(X)
For j = 0 To UBound(Y)
List1.AddItem Y(j)
Next j
For j = 0 To (List1.ListCount - 2)
For r = j + 1 To (List1.ListCount - 1)
If List1.List(j) = List1.List(r) Then
Call ABC(List1.List(j))
End If
Next r
Next j
For j = 0 To List1.ListCount - 1
If Left(List1.List(j), 1) <> "X" Then List2.AddItem List1.List(j)
Next j
Print #2, List2.ListCount
Next i
Close #2
Close #1
End
End Sub
Sub ABC(A)
For i = 0 To List1.ListCount - 1
If A = List1.List(i) Then List1.List(i) = "X" & List1.List(i)
Next i
End Sub
in.txt---------------
3
1 2 3 4 5 6 7 8 9 2 1
2 4 6 8 10
1000 123456 1 2 3 32 2 1 100 1000 9999 9 2
out.txt---------------
7
5
6
Dim m, bar As String
回覆刪除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, T
For i = 1 To T
Line Input #1, n
m = Split(n)
bar = ""
Dim A: A = 0
For k = 0 To UBound(m)
If InStr(bar, m(k)) <> 0 Then A = A - 1: MsgBox m(k) Else A = A + 1
bar = bar & " " & m(k)
Next
Print #2, A
Next
Close
Close
End
End Sub