utilisation de drand48_-

This commit is contained in:
2025-10-08 12:32:29 +02:00
parent cf2109a434
commit f83540153d

View File

@@ -6,10 +6,15 @@
void* nbDansCercleSeq( void* nbLancers ) void* nbDansCercleSeq( void* nbLancers )
{ {
long nb = 0; long nb = 0;
unsigned int seed; struct drand48_data bf;
double x,y;
srand48_r(pthread_self(),&bf); // initialisation de la graine
// avec le numero du thread
for( long i = 0; i < (long) nbLancers; i++ ) { for( long i = 0; i < (long) nbLancers; i++ ) {
double x = (double) rand_r(&seed) / RAND_MAX; drand48_r(&bf,&x);
double y = (double) rand_r(&seed) / RAND_MAX; drand48_r(&bf,&y);
if ( x * x + y * y <= 1.0 ) { if ( x * x + y * y <= 1.0 ) {
nb += 1; nb += 1;
} }