Funcao - converter decimal para romano |
Top Previous Next |
|
// Converte um numero decimal em algarismos romanos function DecToRoman(Decimal: LongInt): string; const Romans : array[1..13] of string = ( 'I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M' ); Arabics: array[1..13] of Integer =( 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000); var I: integer; begin Result := ''; for I := 13 downto 1 do while ( Decimal >= Arabics[I] ) do begin Decimal:= Decimal - Arabics[I]; Result := Result + Romans[I]; end; end; |