COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
main3.cpp
Go to the documentation of this file.
1#include <iostream>
2#include "random.h"
3using namespace std;
4
5int main() {
6
7 int n = 1000000;
8 int count = 0;
9
10 for(int i = 0; i < n; ++i) {
11 double x, y;
12 randomPoint(x, y);
13 if(x*x + y*y < 1) {
14 ++count;
15 }
16 }
17
18 cout << 4.0 * count / n << endl;
19
20 return 0;
21}
int main()
Definition main3.cpp:5
void randomPoint(double &x, double &y)
Definition random.cpp:5