Ayuda

Páginas: 4 (784 palabras) Publicado: 17 de abril de 2010
Generar números aleatorios
Returns a pseudo-random integral number in the range 0 to RAND_MAX. Devuelve un número entero pseudo-aleatorio en el rango de 0 a RAND_MAX.

This number is generated byan algorithm that returns a sequence of apparently non-related numbers each time it is called. Este número es generado por un algoritmo que devuelve una secuencia de números aparentemente norelacionadas con cada vez que se invoca. This algorithm uses a seed to generate the series, which should be initialized to some distinctive value using srand . Este algoritmo utiliza una semilla para generarla serie, que debería ser inicializado a un valor distintivo con srand .

RAND_MAX is a constant defined in . RAND_MAX es una constante definida en . Its default value may vary betweenimplementations but it is granted to be at least 32767. Su valor por defecto puede variar entre las implementaciones, sino que se conceda a ser por lo menos 32.767.

A typical way to generate pseudo-randomnumbers in a determined range using rand is to use the modulo of the returned value by the range span and add the initial value of the range: Una forma típica de generar números pseudo-aleatorios en unrango determinado utilizando rand es utilizar el módulo del valor devuelto por el lapso de rango y agregue el valor inicial de la gama:

( value % 100 ) is in the range 0 to 99 (% Valor de 100) está enel rango 0 a 99
( value % 100 + 1 ) is in the range 1 to 100 (Valor 100% + 1) es en el rango de 1 a 100
( value % 30 + 1985 ) is in the range 1985 to 2014 (30% del valor + 1985) está en el rango1985 a 2014

Notice though that this modulo operation does not generate a truly uniformly distributed random number in the span (since in most cases lower numbers are slightly more likely), but it isgenerally a good approximation for short spans. Aviso sin embargo, que esta operación módulo no genera un número verdaderamente aleatoria uniformemente distribuida en el espacio (ya que en la...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Ayuda
  • Ayudando
  • Ayudar
  • Ayuda
  • Ayuda
  • Ayuda
  • Ayudas
  • Por que no ayudar

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS