随着 n 逐渐增大,Darts函数的输出结果逐渐接近于____。
double rand_double() {
return rand() / (double)RAND_MAX;
}
double Darts(int n) {
int k = 0;
double x, y;
for (int i = 0; i < n; i++) {
x = rand_double();
y = x;
if ((x * x + y * y) <= 1.0)
k++;
}
return k * 4.0 / n;
}