Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
58
Task/Odd-word-problem/PureBasic/odd-word-problem.basic
Normal file
58
Task/Odd-word-problem/PureBasic/odd-word-problem.basic
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#False = 0
|
||||
#True = 1
|
||||
|
||||
Global *inputPtr.Character
|
||||
|
||||
Macro nextChar()
|
||||
*inputPtr + SizeOf(Character)
|
||||
EndMacro
|
||||
|
||||
Procedure isPunctuation(c.s)
|
||||
If FindString("!?()[]{},.;:-'" + #DQUOTE$, c)
|
||||
ProcedureReturn #True
|
||||
EndIf
|
||||
ProcedureReturn #False
|
||||
EndProcedure
|
||||
|
||||
Procedure oddWord()
|
||||
Protected c.c
|
||||
c = *inputPtr\c
|
||||
If isPunctuation(Chr(*inputPtr\c))
|
||||
ProcedureReturn
|
||||
Else
|
||||
nextChar()
|
||||
oddWord()
|
||||
EndIf
|
||||
Print(Chr(c))
|
||||
EndProcedure
|
||||
|
||||
Procedure oddWordProblem(inputStream.s)
|
||||
*inputPtr = @inputStream
|
||||
Define isOdd = #False
|
||||
While *inputPtr\c
|
||||
If isOdd
|
||||
oddWord()
|
||||
Else
|
||||
Repeat
|
||||
Print(Chr(*inputPtr\c))
|
||||
nextChar()
|
||||
Until isPunctuation(Chr(*inputPtr\c))
|
||||
EndIf
|
||||
Print(Chr(*inputPtr\c))
|
||||
isOdd ! 1 ;toggle word indicator
|
||||
nextChar()
|
||||
Wend
|
||||
EndProcedure
|
||||
|
||||
Define inputStream.s
|
||||
If OpenConsole()
|
||||
Repeat
|
||||
PrintN(#CRLF$ + #CRLF$ + "Enter a series of words consisting only of English letters (i.e. a-z, A-Z)")
|
||||
PrintN("and that are separated by a punctuation mark (i.e. !?()[]{},.;:-' or " + #DQUOTE$ + ").")
|
||||
inputStream = Input()
|
||||
oddWordProblem(inputStream) ;assume input is correct
|
||||
Until inputStream = ""
|
||||
|
||||
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input()
|
||||
CloseConsole()
|
||||
EndIf
|
||||
Loading…
Add table
Add a link
Reference in a new issue