Anonymous user
Word break problem: Difference between revisions
m
→{{header|REXX}}: added/changed whitespace and comments.
(Added C++ solution) |
m (→{{header|REXX}}: added/changed whitespace and comments.) |
||
Line 1,171:
=={{header|REXX}}==
This REXX version allows the words to be tested (and the dictionary words) to be specified on the command line.
<lang rexx>/*REXX program breaks up a word (or string) into a list of words from a dictionary.
parse arg a '/' x; a=space(a); x=space(x) /*get optional args; elide extra blanks*/
if a=='' | a=="," then a= 'abcd abbc abcbcd acdbc abcdd'
if x=='' | x=="," then x= 'a bc abc cd b'
na= words(a)
nx= words(x)
say nx ' dictionary words: ' x /*display the words in the dictionary. */
aw= 0 /*maximum word width obtained (so far).*/
say /*display a blank line to the terminal.*/
@.=
xw= 0
do
xw=
p= 0
do
$=
do
$= $
y= substr(y, p + 1)
end /*t*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
|