RosettaCodeData/Task/Last-letter-first-letter/FreeBASIC/last-letter-first-letter.basic
2025-06-11 20:16:52 -04:00

55 lines
1.7 KiB
Text

Dim As String names(69) = { "audino", "bagon", "baltoy", "banette", _
"bidoof", "braviary", "bronzor", "carracosta", "charmeleon", _
"cresselia", "croagunk", "darmanitan", "deino", "emboar", _
"emolga", "exeggcute", "gabite", "girafarig", "gulpin", _
"haxorus", "heatmor", "heatran", "ivysaur", "jellicent", _
"jumpluff", "kangaskhan", "kricketune", "landorus", "ledyba", _
"loudred", "lumineon", "lunatone", "machamp", "magnezone", _
"mamoswine", "nosepass", "petilil", "pidgeotto", "pikachu", _
"pinsir", "poliwrath", "poochyena", "porygon2", "porygonz", _
"registeel", "relicanth", "remoraid", "rufflet", "sableye", _
"scolipede", "scrafty", "seaking", "sealeo", "silcoon", _
"simisear", "snivy", "snorlax", "spoink", "starly", "tirtouga", _
"trapinch", "treecko", "tyrogue", "vigoroth", "vulpix", _
"wailord", "wartortle", "whismur", "wingull", "yamask" }
Dim As String strbegin = "gabite"
Dim As String strdir = "first"
Dim As String ready()
ready(0) = strbegin
Print strbegin
Dim As String strc
Dim As Boolean flag
Dim As Integer i, n, foundIndex
Do
strc = Right(strbegin, 1)
foundIndex = -1
For i = 0 To Ubound(names)
If Left(names(i), 1) = strc Then
flag = True
For n = 0 To Ubound(ready)
If names(i) = ready(n) Then
flag = False
Exit For
End If
Next
If flag Then
foundIndex = i
Exit For
End If
End If
Next
If foundIndex = -1 Then Exit Do
Redim Preserve ready(Ubound(ready) + 1)
ready(Ubound(ready)) = names(foundIndex)
Print names(foundIndex)
strbegin = names(foundIndex)
strdir = Iif(strdir = "first", "last", "first")
Loop
Sleep