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
"
3
using namespace
std;
4
5
int
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
}
main
int main()
Definition
main3.cpp:5
randomPoint
void randomPoint(double &x, double &y)
Definition
random.cpp:5
random.h
Assignment2
P3
main3.cpp
Generated on Sun Sep 29 2024 16:39:53 for COMP2113 by
1.12.0