Ver Mensaje Individual
  #2 (permalink)  
Antiguo 11/11/2014, 10:16
eferion
 
Fecha de Ingreso: octubre-2014
Ubicación: Madrid
Mensajes: 1.212
Antigüedad: 9 años, 7 meses
Puntos: 204
Respuesta: funciones recursivas

Una aproximación:

Código C++:
Ver original
  1. int f( int numero )
  2. {
  3.   int cifras = (int)log10( numero );
  4.   if ( cifras == 0 )
  5.     return 0;
  6.  
  7.   int ultimo = numero % 10;
  8.   int primero = numero / pow( 10, cifras );
  9.  
  10.   numero -= primero * pow( 10, cifras );
  11.  
  12.   int to_return = f( numero );
  13.  
  14.   if ( primero >= ultimo )
  15.   {
  16.     if ( to_return != 0 )
  17.       to_return *= primero;
  18.     else
  19.       to_return = primero;
  20.   }
  21.  
  22.   return to_return;
  23. }

Última edición por eferion; 11/11/2014 a las 10:20 Razón: He reducido el número de "returns"