有一英文文章,vb编程统计出26个字母中,出现频率最高的前5个字母,不区分大小写
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/18 05:14:39
有一英文文章,vb编程统计出26个字母中,出现频率最高的前5个字母,不区分大小写
Private Sub Command1_Click()
Dim t As String,c As String,s(25) As Long,n(25) As Long,i As Long,j As Long,k As Long
Open "e:\tmp\123.txt" For Binary As #1
t = Input(LOF(1),#1)
Close #1
For i = 0 To 25
n(i) = i
Next
For i = 1 To Len(t)
c = LCase(Mid(t,i,1))
If c >= "a" And c <= "z" Then s(Asc(c) - Asc("a")) = s(Asc(c) - Asc("a")) + 1
Next
For i = 0 To 24
For j = i + 1 To 25
If s(i) < s(j) Then
k = s(i)
s(i) = s(j)
s(j) = k
k = n(i)
n(i) = n(j)
n(j) = k
End If
Next
Next
For i = 0 To 4
Print "No."; i + 1,Chr(n(i) + Asc("a")); " ("; s(i); ")"
Next
End Sub
以上代码假定英文文章是在e:\tmp\123.txt文件中
再问: 咋会 下标越界 指向n(i) = i 有误
再答: n(25) As Long这个声明了吗?声明了的话应该不会有错的。 另外整个窗体代码的通用部分不能有 Option Base 1 我已经测试通过了。
Dim t As String,c As String,s(25) As Long,n(25) As Long,i As Long,j As Long,k As Long
Open "e:\tmp\123.txt" For Binary As #1
t = Input(LOF(1),#1)
Close #1
For i = 0 To 25
n(i) = i
Next
For i = 1 To Len(t)
c = LCase(Mid(t,i,1))
If c >= "a" And c <= "z" Then s(Asc(c) - Asc("a")) = s(Asc(c) - Asc("a")) + 1
Next
For i = 0 To 24
For j = i + 1 To 25
If s(i) < s(j) Then
k = s(i)
s(i) = s(j)
s(j) = k
k = n(i)
n(i) = n(j)
n(j) = k
End If
Next
Next
For i = 0 To 4
Print "No."; i + 1,Chr(n(i) + Asc("a")); " ("; s(i); ")"
Next
End Sub
以上代码假定英文文章是在e:\tmp\123.txt文件中
再问: 咋会 下标越界 指向n(i) = i 有误
再答: n(25) As Long这个声明了吗?声明了的话应该不会有错的。 另外整个窗体代码的通用部分不能有 Option Base 1 我已经测试通过了。
有一英文文章,vb编程统计出26个字母中,出现频率最高的前5个字母,不区分大小写
C语言编程:输入一串英文字母,统计每个字母(不区分大小写)出现的次数
26个字母出现频率最高的字母什么?
英语中出现频率最高的2个字母是.
我们都知道英文有26个字母,这26个字母构成了整个英语的词汇,那你知道有那两个字母出现频率最高?
输入一篇英文文章,以$符号结束,统计其中出现字母,数字的个数,求出现频率最高的字母
英文中26个字母出现的频率
26个字母中共有5个元音字母,请写出元音字母的大小写
我们都知道英文有26个字母,这26个字母构成了整个英语的所有词汇,可是你知道在英语当中,哪两个字母的出现频率最高?
26个字母的大小写
写出26个字母中五个元音字母的大小写
统计英文字符串中以各种字母为首的单词数量(单词之间用空格或其他非字母字符分隔),不区分大小写