Data update
This commit is contained in:
parent
0df55f9f24
commit
aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions
41
Task/Function-frequency/FreeBASIC/function-frequency.basic
Normal file
41
Task/Function-frequency/FreeBASIC/function-frequency.basic
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
Dim As String code, word, char
|
||||
Dim As Integer i, j
|
||||
Dim As String words()
|
||||
Dim As Integer counts()
|
||||
|
||||
Open "i:\your_file.bas" For Input As #1
|
||||
While Not Eof(1)
|
||||
Line Input #1, code
|
||||
For i = 1 To Len(code)
|
||||
char = Lcase(Mid(code, i, 1))
|
||||
If char >= "a" And char <= "z" Then
|
||||
word &= Mid(code, i, 1)
|
||||
Elseif word <> "" Then
|
||||
For j = 0 To Ubound(words)
|
||||
If words(j) = word Then
|
||||
counts(j) += 1
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
If j > Ubound(words) Then
|
||||
Redim Preserve words(Ubound(words) + 1)
|
||||
Redim Preserve counts(Ubound(counts) + 1)
|
||||
words(Ubound(words)) = word
|
||||
counts(Ubound(counts)) = 1
|
||||
End If
|
||||
word = ""
|
||||
End If
|
||||
Next
|
||||
Wend
|
||||
Close #1
|
||||
|
||||
For i = 0 To 9
|
||||
Dim As Integer maxj = 0
|
||||
For j = 0 To Ubound(counts)
|
||||
If counts(j) > counts(maxj) Then maxj = j
|
||||
Next
|
||||
Print words(maxj); " occurs"; counts(maxj); " times"
|
||||
counts(maxj) = 0
|
||||
Next
|
||||
|
||||
Sleep
|
||||
Loading…
Add table
Add a link
Reference in a new issue