| Ver tema anterior :: Ver tema siguiente |
| Autor |
Mensaje |
Luis_ Invitado
|
Publicado: Jue 28 Abr, 2005 11:20 am Asunto: Generar números aleatorios |
|
|
| Alguien me puede recordar como se generaban numeros aleatzorios entre 1 y 75, me acuerdo que eran con las funciones srand(9 o algo así pero no tengo nada a mano y no lo recuerdo exacto como se hacia, Gracias |
|
| Volver arriba |
|
 |
rayder Master

Registrado: 03 Mar 2004Mensajes: 207
|
Publicado: Jue 28 Abr, 2005 11:30 am Asunto: |
|
|
De la ayuda del builder 6 ent.
| Código: |
Header File:
stdlib.h
Category:
Math Routines
Prototype:
int rand(void);
Description
Random number generator.
rand uses a multiplicative congruential random number generator with period 2 to the 32nd power to return successive pseudo-random numbers in the range from 0 to RAND_MAX. The symbolic constant RAND_MAX is defined in stdlib.h.
Return Value:
rand returns the generated pseudo-random number.
|
Y un ejemplo, por si acaso
| Código: |
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
int i;
randomize();
printf("Ten random numbers from 0 to 99\n\n");
for(i=0; i<10; i++)
printf("%d\n", rand() % 100);
return 0;
}
|
_________________ Un saludo
Rayder |
|
| Volver arriba |
|
 |
|