Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
42
Task/Ordered-words/FreeBASIC/ordered-words.freebasic
Normal file
42
Task/Ordered-words/FreeBASIC/ordered-words.freebasic
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
' 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue