Private Sub Form_Load() Me.Hide Dim f(10000) 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 Line Input #1, x a = Split(x) For j = 0 To UBound(a) f(a(j)) = f(a(j)) + 1 Next ans = 0 For k = 0 To 10000 If f(k) = 1 Then ans = ans + 1 Next Print #2, ans Next Close Close End 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 Dim num(1000) As Integer Input #1, n For i = 1 To n Line Input #1, a x = Split(a) For j = 0 To UBound(x) num(Val(x(j))) = num(Val(x(j))) + 1 Next j ans = 0 For k = 1 To 1000 If num(k) = 1 Then ans = ans + 1 Next k Print #2, ans Next i Close Close End 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 Val(n) Line Input #1, a b = Split(a) ans = 0 For j = 0 To UBound(b) For r = j To UBound(b) If j <> r Then If InStr(b(r), b(j)) > 0 Then b(r) = "": b(j) = "" End If Next r Next j For j = 0 To UBound(b) If b(j) <> "" Then ans = ans + 1 Next j Print #2, ans Next i Close #2 Close #1 End End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Dim f(10000)
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
Line Input #1, x
a = Split(x)
For j = 0 To UBound(a)
f(a(j)) = f(a(j)) + 1
Next
ans = 0
For k = 0 To 10000
If f(k) = 1 Then ans = ans + 1
Next
Print #2, ans
Next
Close
Close
End
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
Dim num(1000) As Integer
Input #1, n
For i = 1 To n
Line Input #1, a
x = Split(a)
For j = 0 To UBound(x)
num(Val(x(j))) = num(Val(x(j))) + 1
Next j
ans = 0
For k = 1 To 1000
If num(k) = 1 Then ans = ans + 1
Next k
Print #2, ans
Next i
Close
Close
End
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 Val(n)
Line Input #1, a
b = Split(a)
ans = 0
For j = 0 To UBound(b)
For r = j To UBound(b)
If j <> r Then
If InStr(b(r), b(j)) > 0 Then b(r) = "": b(j) = ""
End If
Next r
Next j
For j = 0 To UBound(b)
If b(j) <> "" Then ans = ans + 1
Next j
Print #2, ans
Next i
Close #2
Close #1
End
End Sub