生成罗马数字的Delphi函数

来源:互联网 发布:淘宝中小卖家 编辑:程序博客网 时间:2024/05/22 15:11
 
  1. function DecToRom(Dec: LongInt): String;
  2. const
  3.   Nums : Array[1..13of Integer =
  4.     (145910405090100,
  5.       4005009001000);
  6.   RomanNums:  Array[1..13of string =
  7.     ('I''IV''V''IX''X''XL',
  8.       'L''XC''C''CD''D''CM''M');
  9. var
  10.   i: Integer;
  11. begin
  12.   Result := '';
  13.   for i := 13 downto 1 do
  14.     while (Dec >= Nums[i]) do
  15.     begin
  16.       Dec := Dec - Nums[i];
  17.       Result  := Result + RomanNums[i];
  18.     end;
  19. end;
原创粉丝点击