Red de conocimiento informático - Material del sitio web - Cómo generar números aleatorios distribuidos normales usando lenguaje C, código fuente adjunto ~ ¡Gracias!

Cómo generar números aleatorios distribuidos normales usando lenguaje C, código fuente adjunto ~ ¡Gracias!

Genera cien números aleatorios del 1 al 100.

#include

#include

#include

# definir N 100

int main(int argc, char *argv[])

{

int i;

int a[ N];

srand(time(NULL));

for(i=0;i

a[i]=rand ()%101;

printf("El número aleatorio generado es:\n");

for(i=0;i

{

printf("%5d",a[i]);

if((i+1)%10==0)

printf("\n");

}

system("PAUSA");

devuelve 0;

}

El resultado es el siguiente:

Los números aleatorios generados son los siguientes:

41 15 82 1 23 51 16 96 92 17

86 71 87 69 74 5 50 18 42 52<

46 34 52 18 40 74 79 35 22 36

65 94 80 91 18 72 61 79 4 11

61 30 95 55 11 19 38 87 78 52

95 30 99 5399 99 10 79 70 33

91 85 10 99 47 58 93 41 19 71

56 60 Presione cualquier tecla para continuar. .