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 j = 1 To t Line Input #1, a a = LCase(a) ans = 0 For i = 1 To Len(a) m = Mid(a, i, 1) If m >= "a" And m <= "z" 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
Input #1, N
For i = 1 To N
Line Input #1, X
X = LCase(X)
ans = 0
For j = 1 To Len(X)
Y = Mid(X, j, 1)
If Y >= "a" And Y <= "z" Then ans = ans + 1
Next j
Print #2, ans
Next i
Close #2
Close #1
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, t
For j = 1 To t
Line Input #1, a
a = LCase(a)
ans = 0
For i = 1 To Len(a)
m = Mid(a, i, 1)
If m >= "a" And m <= "z" Then ans = ans + 1
Next
Print #2, ans
Next
Close
Close
End
End Sub
柯佑,arro好,
回覆刪除程式都正確。
還可以用replace將數字給取代成空字串,剩下的字串長度就是答案了。