Private Sub Form_Load()Me.HideOpen App.Path & "\in.txt" For Input As #1Open App.Path & "\out.txt" For Output As #2Dim s, a As String, m As String, ans As Integer, ch, outsouts = Split("! , . ~ , 。 : ; 、")Input #1, TiFor times = 1 To (Ti * 2) - 1List1.ClearFor j = 0 To UBound(outs)List1.AddItem Asc(outs(j))Nextans = 0Input #1, aFor i = 1 To Len(a)m = Mid(a, i, 1)ch = 1For j = 0 To List1.ListCount - 1If Asc(m) = List1.List(j) Then ch = 0NextIf ch = 1 Then ans = ans + 1: List1.AddItem Asc(m)NextIf times Mod 2 <> 0 Then Print #2, ansNextCloseCloseEndEnd Sub
arro好, 1.這題似乎怪怪的,你反過來去算標點符號有那些,但是,標點符號只有這些嗎? 你之前不是寫過一題,直接去求中文的內碼值? 就算是全形的標點符號,應該也是在同一區才是吧。 2.字串符號那個"雙引號,在vb 中要怎麼表示呢? 3.兩個星期過去了,怎麼才這麼幾題呢? 還有去找緣尉要寫寫吧。 加油。
Private Sub Form_Load()Me.HideOpen App.Path & "\in.txt" For Input As #1Open App.Path & "\out.txt" For Output As #2Input #1, NDo If Not EOF(1) Then Input #1, X Else X = "" Call ABC(X) If Len(X) = 0 Then Print #2, List1.ListCount N = N - 1 List1.Clear End IfLoop Until N = 0EndEnd SubSub ABC(A)For i = 1 To Len(A)T = Asc(Mid(A, i, 1))If T < 0 Then If RE(T) = False Then List1.AddItem TEnd IfNext iEnd SubFunction RE(A) As BooleanP = FalseFor i = 0 To List1.ListCount - 1If A = Val(List1.List(i)) Then P = True: Exit ForNext iRE = PEnd Function
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 s, a As String, m As String, ans As Integer, ch, outs
outs = Split("! , . ~ , 。 : ; 、")
Input #1, Ti
For times = 1 To (Ti * 2) - 1
List1.Clear
For j = 0 To UBound(outs)
List1.AddItem Asc(outs(j))
Next
ans = 0
Input #1, a
For i = 1 To Len(a)
m = Mid(a, i, 1)
ch = 1
For j = 0 To List1.ListCount - 1
If Asc(m) = List1.List(j) Then ch = 0
Next
If ch = 1 Then ans = ans + 1: List1.AddItem Asc(m)
Next
If times Mod 2 <> 0 Then Print #2, ans
Next
Close
Close
End
End Sub
arro好,
回覆刪除1.這題似乎怪怪的,你反過來去算標點符號有那些,但是,標點符號只有這些嗎?
你之前不是寫過一題,直接去求中文的內碼值?
就算是全形的標點符號,應該也是在同一區才是吧。
2.字串符號那個"雙引號,在vb 中要怎麼表示呢?
3.兩個星期過去了,怎麼才這麼幾題呢? 還有去找緣尉要寫寫吧。
加油。
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
Do
If Not EOF(1) Then Input #1, X Else X = ""
Call ABC(X)
If Len(X) = 0 Then
Print #2, List1.ListCount
N = N - 1
List1.Clear
End If
Loop Until N = 0
End
End Sub
Sub ABC(A)
For i = 1 To Len(A)
T = Asc(Mid(A, i, 1))
If T < 0 Then
If RE(T) = False Then List1.AddItem T
End If
Next i
End Sub
Function RE(A) As Boolean
P = False
For i = 0 To List1.ListCount - 1
If A = Val(List1.List(i)) Then P = True: Exit For
Next i
RE = P
End Function