~cpp #include <iostream> #include <time.h> #include <math.h> using namespace std; unsigned int max = 1000000; int main() { double x, y; int count = 0; srand(time(NULL)); for(int i = 0; i < max; i++) { x = rand(); y = rand(); x = x/RAND_MAX; y = y/RAND_MAX; if(sqrt(x*x + y*y) <= 1) // cout << x << " " << y << endl; count++; } cout << 4*(double)count/max << endl; return 0; }