Paste: dumb method
Author: | no one who is proud |
Mode: | c++ |
Date: | Thu, 19 Apr 2012 04:04:38 |
Plain Text |
/*
Developed by Reginald Ford
April 18, 2012
*/
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
static int max_count = 99999999;
double x;
double y;
int num_inside=0;
for(int count = 0; count < max_count ; count++)
{
x = rand()/(double)RAND_MAX;
y = rand()/(double)RAND_MAX;
if(x * x + y * y <= 1.0)
{
num_inside ++;
}
}
cout<<"pi is about "<<(double)4.0 * num_inside / max_count<<endl;
}
New Annotation