#includeusing namespace std;//概率计算PIint main(){ int inside=0; double val; int i; for ( i=0; i<100000000; i++) { double x = (double)(rand())/RAND_MAX; double y = (double)(rand())/RAND_MAX; if ( (x*x + y*y) <= 1.0 ) { inside++; } } val = (double)inside / i; printf("PI = %.4g\n", val*4); return 0;}