Ver Mensaje Individual
  #205 (permalink)  
Antiguo 21/08/2010, 08:36
Avatar de truman_truman
truman_truman
 
Fecha de Ingreso: febrero-2010
Ubicación: /home/user
Mensajes: 1.341
Antigüedad: 14 años, 2 meses
Puntos: 177
Respuesta: Reto: Números Romanos

pues claroo. si presento mi codigo sin comentarios ni espacios es obvio que tendrá menos lines....
Código PHP:
Ver original
  1. <?php
  2. $db = array (0 => array(1=>"I", 2=>"II", 3=>"III", 4=>"IV", 5=>"V", 6=>"VI", 7=>"VII", 8=>"VIII", 9=>"IX"),  
  3.              1 => array( 1=>"X", 2=>"XX", 3=>"XXX", 4=>"XL", 5=>"L", 6=>"LX", 7=>"LXX", 8=>"LXXX", 9=>"XC"),
  4.              2 => array( 1=>"C", 2=>"CC", 3=>"CCC", 4=>"CD", 5=>"D", 6=>"DC", 7=>"DCC", 8=>"DCCC", 9=>"CM"),
  5.              3 => array( 1=>"M", 2=>"MM", 3=>"MMM", 4=>"MMMM", 5=>"MMMMM", 6=>"MMMMMM", 7=>"MMMMMMM", 8=>"MMMMMMMM", 9=>"MMMMMMMMM"),);
  6. function romanNumber($numero_aleatorio){
  7.       global $db;
  8.       $cifra = $numero_aleatorio;
  9.       $cifra = strrev($cifra);
  10.       $cant_caract = strlen($cifra);
  11.       $numeros = str_split($cifra);
  12.       for ($i=$cant_caract; $i >= 0; $i--){
  13.          $rresult .= $db[$i][$numeros[$i]];
  14.      }
  15. return $rresult;
  16. }
  17. ?>
__________________
la la la