Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,23 @@
|
|||
100 cls : rem 100 home for Applesoft BASIC
|
||||
110 roman$ = "MCMXCIX" : print roman$,"=> "; : gosub 170 : print decimal '1999
|
||||
120 roman$ = "XXV" : print roman$,"=> "; : gosub 170 : print decimal '25
|
||||
130 roman$ = "CMLIV" : print roman$,"=> "; : gosub 170 : print decimal '954
|
||||
140 roman$ = "MMXI" : print roman$,"=> "; : gosub 170 : print decimal '2011
|
||||
150 end
|
||||
160 rem Decode from roman
|
||||
170 decimal = 0
|
||||
180 predecimal = 0
|
||||
190 for i = len(roman$) to 1 step -1
|
||||
200 x$ = mid$(roman$,i,1)
|
||||
210 if x$ = "M" then n = 1000 : goto 280
|
||||
220 if x$ = "D" then n = 500 : goto 280
|
||||
230 if x$ = "C" then n = 100 : goto 280
|
||||
240 if x$ = "L" then n = 50 : goto 280
|
||||
250 if x$ = "X" then n = 10 : goto 280
|
||||
260 if x$ = "V" then n = 5 : goto 280
|
||||
270 if x$ = "I" then n = 1
|
||||
280 if n < predecimal then decimal = decimal-n
|
||||
285 if n >= predecimal then decimal = decimal+n
|
||||
290 predecimal = n
|
||||
300 next i
|
||||
310 return
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
100 cls
|
||||
110 roman$ = "MCMXCIX" : print roman$,"=> "; : gosub 170 : print decimal '1999
|
||||
120 roman$ = "XXV" : print roman$,"=> "; : gosub 170 : print decimal '25
|
||||
130 roman$ = "CMLIV" : print roman$,"=> "; : gosub 170 : print decimal '954
|
||||
140 roman$ = "MMXI" : print roman$,"=> "; : gosub 170 : print decimal '2011
|
||||
150 end
|
||||
160 rem Decode from roman
|
||||
170 decimal = 0
|
||||
180 predecimal = 0
|
||||
190 for i = len(roman$) to 1 step -1
|
||||
200 x$ = mid$(roman$,i,1)
|
||||
210 select case x$
|
||||
220 case "M" : n = 1000
|
||||
230 case "D" : n = 500
|
||||
240 case "C" : n = 100
|
||||
250 case "L" : n = 50
|
||||
260 case "X" : n = 10
|
||||
270 case "V" : n = 5
|
||||
280 case "I" : n = 1
|
||||
290 case else : print "not a roman numeral" : end
|
||||
300 end select
|
||||
310 if n < predecimal then decimal = decimal-n else decimal = decimal+n
|
||||
320 predecimal = n
|
||||
330 next i
|
||||
340 return
|
||||
Loading…
Add table
Add a link
Reference in a new issue