43 lines
910 B
Plaintext
43 lines
910 B
Plaintext
' FB 1.05.0 Win64
|
|
|
|
Function isOrdered(s As Const String) As Boolean
|
|
If Len(s) <= 1 Then Return True
|
|
For i As Integer = 1 To Len(s) - 1
|
|
If s[i] < s[i - 1] Then Return False
|
|
Next
|
|
Return True
|
|
End Function
|
|
|
|
Dim words() As String
|
|
Dim word As String
|
|
Dim maxLength As Integer = 0
|
|
Dim count As Integer = 0
|
|
Open "undict.txt" For Input As #1
|
|
While Not Eof(1)
|
|
Line Input #1, word
|
|
If isOrdered(word) Then
|
|
If Len(word) = maxLength Then
|
|
Redim Preserve words(0 To count)
|
|
words(count) = word
|
|
count += 1
|
|
ElseIf Len(word) > maxLength Then
|
|
Erase words
|
|
maxLength = Len(word)
|
|
Redim words(0 To 0)
|
|
words(0) = word
|
|
count = 1
|
|
End If
|
|
End If
|
|
Wend
|
|
|
|
Close #1
|
|
|
|
Print "The ordered words with the longest length ("; Str(maxLength); ") in undict.txt are :"
|
|
Print
|
|
For i As Integer = 0 To UBound(words)
|
|
Print words(i)
|
|
Next
|
|
Print
|
|
Print "Press any key to quit"
|
|
Sleep
|