Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
29
Task/Roman-numerals-Decode/ERRE/roman-numerals-decode.erre
Normal file
29
Task/Roman-numerals-Decode/ERRE/roman-numerals-decode.erre
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
PROGRAM ROMAN2ARAB
|
||||
|
||||
DIM R%[7]
|
||||
|
||||
PROCEDURE TOARAB(ROMAN$->ANS%)
|
||||
LOCAL I%,J%,P%,N%
|
||||
FOR I%=LEN(ROMAN$) TO 1 STEP -1 DO
|
||||
J%=INSTR("IVXLCDM",MID$(ROMAN$,I%,1))
|
||||
IF J%=0 THEN
|
||||
ANS%=-9999 ! illegal character
|
||||
EXIT PROCEDURE
|
||||
END IF
|
||||
IF J%>=P% THEN
|
||||
N%+=R%[J%]
|
||||
ELSE
|
||||
N%-=R%[J%]
|
||||
END IF
|
||||
P%=J%
|
||||
END FOR
|
||||
ANS%=N%
|
||||
END PROCEDURE
|
||||
|
||||
BEGIN
|
||||
R%[]=(0,1,5,10,50,100,500,1000)
|
||||
TOARAB("MCMXCIX"->ANS%) PRINT(ANS%)
|
||||
TOARAB("MMXII"->ANS%) PRINT(ANS%)
|
||||
TOARAB("MDCLXVI"->ANS%) PRINT(ANS%)
|
||||
TOARAB("MMMDCCCLXXXVIII"->ANS%) PRINT(ANS%)
|
||||
END PROGRAM
|
||||
Loading…
Add table
Add a link
Reference in a new issue