Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
42
Task/Roman-numerals-Encode/BCPL/roman-numerals-encode.bcpl
Normal file
42
Task/Roman-numerals-Encode/BCPL/roman-numerals-encode.bcpl
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
get "libhdr"
|
||||
|
||||
let toroman(n, v) = valof
|
||||
$( let extract(n, val, rmn, v) = valof
|
||||
$( while n >= val
|
||||
$( n := n - val;
|
||||
for i=1 to rmn%0 do v%(v%0+i) := rmn%i
|
||||
v%0 := v%0 + rmn%0
|
||||
$)
|
||||
resultis n
|
||||
$)
|
||||
|
||||
v%0 := 0
|
||||
n := extract(n, 1000, "M", v)
|
||||
n := extract(n, 900, "CM", v)
|
||||
n := extract(n, 500, "D", v)
|
||||
n := extract(n, 400, "CD", v)
|
||||
n := extract(n, 100, "C", v)
|
||||
n := extract(n, 90, "XC", v)
|
||||
n := extract(n, 50, "L", v)
|
||||
n := extract(n, 40, "XL", v)
|
||||
n := extract(n, 10, "X", v)
|
||||
n := extract(n, 9, "IX", v)
|
||||
n := extract(n, 5, "V", v)
|
||||
n := extract(n, 4, "IV", v)
|
||||
n := extract(n, 1, "I", v)
|
||||
resultis v
|
||||
$)
|
||||
|
||||
let show(n) be
|
||||
$( let v = vec 50
|
||||
writef("%I4 = %S*N", n, toroman(n, v))
|
||||
$)
|
||||
|
||||
let start() be
|
||||
$( show(1666)
|
||||
show(2008)
|
||||
show(1001)
|
||||
show(1999)
|
||||
show(3888)
|
||||
show(2021)
|
||||
$)
|
||||
Loading…
Add table
Add a link
Reference in a new issue