Anonymous user
Dinesman's multiple-dwelling problem: Difference between revisions
m
→{{header|REXX}}: changed whitespace.
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: revised where 'warnings' pragma used) |
m (→{{header|REXX}}: changed whitespace.) |
||
Line 3,590:
names= 'Baker Cooper Fletcher Miller Smith' /*names of multiple─dwelling tenants. */
#tenants= words(names) /*the number of tenants in the building*/
floors= 5; top= floors; bottom= 1
say 'found '
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
set: do p=1 for #tenants; call value word(names, p), @.p; end; return
s: if arg(1)=1 then return ''; return "s" /*a simple pluralizer function.*/
th: arg x; x=abs(x); return word('th st nd rd', 1 +x// 10* (x//100%10\==1)*(x//10<4))
Line 3,623:
if Smith == Fletcher - 1 | Smith == Fletcher + 1 then return
if Fletcher == Cooper - 1 | Fletcher == Cooper + 1 then return
say; do p=1 for #tenants; tenant= word(names, p)
say right(tenant, 35) 'lives on the' @.p || th(@.p) "floor."
end /*p*/ /* [↑] "||" is REXX's concatenation. */
|