Roman numerals/Encode: Difference between revisions

Content added Content deleted
Line 3,130: Line 3,130:


<syntaxhighlight lang="text">
<syntaxhighlight lang="text">
proc dec2rom dec . rom$ .
func$ dec2rom dec .
values[] = [ 1000 900 500 400 100 90 50 40 10 9 5 4 1 ]
values[] = [ 1000 900 500 400 100 90 50 40 10 9 5 4 1 ]
symbol$[] = [ "M" "CM" "D" "CD" "C" "XC" "L" "XL" "X" "IX" "V" "IV" "I" ]
symbol$[] = [ "M" "CM" "D" "CD" "C" "XC" "L" "XL" "X" "IX" "V" "IV" "I" ]
rom$ = ""
for i = 1 to len values[]
for i = 1 to len values[]
while dec >= values[i]
while dec >= values[i]
Line 3,140: Line 3,139:
.
.
.
.
return rom$
.
.
dec2rom 1990 r$
print dec2rom 1990
print r$
print dec2rom 2008
print dec2rom 1666
dec2rom 2008 r$
print r$
dec2rom 1666 r$
print r$
</syntaxhighlight>
</syntaxhighlight>