// Adapted from Dr. John Stockton's Math Page // www.merlyn.demon.co.uk/programs/wr-roman.pas // efg tested through 300 function Roman(CONST Number: LongWord) : string; const Digits = 7 ; type Decades = 0..Pred(Digits); const Pattern : array ['0'..'9'] of string [4] = ('', 'x', 'xx', 'xxx', 'xy', 'y', 'yx', 'yxx', 'yxxx', 'xz') ; const DecXlatn : array [Decades] of array ['x'..'z'] of char = ('IVX', 'XLC', 'CDM', 'Mvx', 'xlc', 'cdm', 'm??' {, ...}) ; var DigitNum: byte; CharNumb: byte; NumStr : string[10]; ChrPattn: string[4]; PartRomn: string[4]; begin RESULT := '' ; NumStr := IntToStr(Number); if Length(NumStr) > Digits then RESULT := 'Too Big' else begin for DigitNum := 1 to Length(NumStr) do begin ChrPattn := Pattern[NumStr[DigitNum]]; PartRomn[0] := ChrPattn[0]; for CharNumb := 1 to Length(ChrPattn) do PartRomn[CharNumb] := DecXlatn[Length(NumStr)-DigitNum][ChrPattn[CharNumb]] ; RESULT := RESULT + PartRomn end {DigitNum} end end {Roman};