Skip to content

Instantly share code, notes, and snippets.

@splitline
Created December 16, 2016 19:13
Show Gist options
  • Save splitline/dae7d533daf9ea6dc8c8491a77f3b88f to your computer and use it in GitHub Desktop.
Save splitline/dae7d533daf9ea6dc8c8491a77f3b88f to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define RANDOM (double)rand()/RAND_MAX
int main()
{
double x,y,z,counter;
long int n=100000000,N=n;
srand(time(NULL));
counter=0;
while(n--)
{
x=RANDOM*10;
y=RANDOM*10;
z=RANDOM*14;
double test=9.8*exp(-(x-3.1)*(x-3.1)/7.9-(y-4.3)*(y-4.3)/12)+12*exp(-(x-7.1)*(x-7.1)/2.0-(y-8.2)*(y-8.2)/6.0);
if(z<=test)counter++;
}
printf("N=%d\n%.6f\n",N,counter/N*1400);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment