Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
31
Task/Odd-word-problem/FreeBASIC/odd-word-problem.basic
Normal file
31
Task/Odd-word-problem/FreeBASIC/odd-word-problem.basic
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
Dim Shared As Integer n1 = 1
|
||||
|
||||
Function reverseString(texto As String) As String
|
||||
Dim As Integer x, lt = Len(texto)
|
||||
For x = 0 To lt Shr 1 - 1
|
||||
Swap texto[x], texto[lt - x - 1]
|
||||
Next x
|
||||
Return texto
|
||||
End Function
|
||||
|
||||
Sub process(texto As String)
|
||||
Dim As Integer c = 0, n2
|
||||
Dim As String tmptexto
|
||||
|
||||
Print "Input stream: "; texto
|
||||
Print "Output stream: ";
|
||||
Do
|
||||
n2 = Instr(texto, Any ",;:.")
|
||||
tmptexto = Mid(texto, n1, n2-1)
|
||||
Print Iif(c Mod 2 = 0, tmptexto, reverseString(tmptexto)); Mid(texto, n2, 1);
|
||||
If Mid(texto, n2, 1) = "." Then Exit Do
|
||||
texto = Mid(texto, n2+1, Len(texto))
|
||||
c += 1
|
||||
Loop
|
||||
Print !"\n"
|
||||
End Sub
|
||||
|
||||
process("what,is,the;meaning,of:life.")
|
||||
process("we,are;not,in,kansas;any,more.")
|
||||
|
||||
Sleep
|
||||
Loading…
Add table
Add a link
Reference in a new issue