輸入說明:
第一行是要建立關鍵字的英文文章篇數,第二行開始為英文文章的內容。每篇文章之間,以一行空白作為區隔。在建立關鍵字時,我們簡化一些文法上的規則,每個英文單字與英文單字之間,扣除標點符號之後,以空白作為區別,稱之為一個單字,大小寫視為相同。使用到的標點符號則包括下列三個:『,』,『.』,以及『:』。
輸出說明:
對輸入的每篇文章,分別以一行輸出使用的英文字字數。
輸入範例:
2
He works hard from morning till night. He is a hard worker.
I once heard him speaking in English. He is a very good speaker of English .
輸出範例:
10
14
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, x
For i = 1 To x
ans = 0
Line Input #1, n
n = Replace(n, ",", " ")
n = Replace(n, ".", " ")
n = Replace(n, ":", " ")
a = Split(n, " ")
For y = 0 To UBound(a)
a(y) = LCase(a(y))
If Mid(a(y), 1, 1) >= "a" And Mid(a(y), 1, 1) <= "z" Then ans = ans + 1
Next
c = 0
For y = 0 To UBound(a) - 1
For j = y + 1 To UBound(a) - 1
If a(y) = a(j) And a(j) <> " " Then ans = ans - 1
Next
Next
Print #2, ans
Next
Close
Close
End
End Sub