Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
function romToDec (roman$)
|
||||
num = 0
|
||||
prenum = 0
|
||||
for i = length(roman$) to 1 step -1
|
||||
x$ = mid(roman$, i, 1)
|
||||
n = 0
|
||||
if x$ = "M" then n = 1000
|
||||
if x$ = "D" then n = 500
|
||||
if x$ = "C" then n = 100
|
||||
if x$ = "L" then n = 50
|
||||
if x$ = "X" then n = 10
|
||||
if x$ = "V" then n = 5
|
||||
if x$ = "I" then n = 1
|
||||
|
||||
if n < preNum then num -= n else num += n
|
||||
preNum = n
|
||||
next i
|
||||
|
||||
return num
|
||||
end function
|
||||
|
||||
#Testing
|
||||
print "MCMXCIX = "; romToDec("MCMXCIX") #1999
|
||||
print "MDCLXVI = "; romToDec("MDCLXVI") #1666
|
||||
print "XXV = "; romToDec("XXV") #25
|
||||
print "CMLIV = "; romToDec("CMLIV") #954
|
||||
print "MMXI = "; romToDec("MMXI") #2011
|
||||
Loading…
Add table
Add a link
Reference in a new issue