-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2to12.cpp
More file actions
68 lines (62 loc) · 1.42 KB
/
Copy path2to12.cpp
File metadata and controls
68 lines (62 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
#include <cstdlib>
using namespace std;
int RandomInt(int first, int last);
int i, x, a, b, c, d, e, f, g, h, m, j, k, l, result;
int main () {
for(i = 0; i < 6000; i++){
x = RandomInt(2, 12);
if(x == 2){
a = a + 1;
}
else if(x == 3){
b = b + 1;
}
else if(x == 4){
c = c + 1;
}
else if(x == 5){
d = d + 1;
}
else if(x == 6){
e = e + 1;
}
else if(x == 7){
f = f + 1;
}
else if(x == 8){
g = g + 1;
}
else if(x == 9){
h = h + 1;
}
else if(x == 10){
m = m + 1;
}
else if(x == 11){
j = j + 1;
}
else if(x == 12){
k = k + 1;
}
}
cout << "2 occured = " << a << endl;
cout << "3 occured = " << b << endl;
cout << "4 occured = " << c << endl;
cout << "5 occured = " << d << endl;
cout << "6 occured = " << e << endl;
cout << "7 occured = " << f << endl;
cout << "8 occured = " << g << endl;
cout << "9 occured = " << h << endl;
cout << "10 occured = " << m << endl;
cout << "11 occured = " << j << endl;
cout << "12 occured = " << k << endl;
result = a + b + c + d + e + f + g + h + m + j + k;
cout << result << endl;
}
int RandomInt(int first, int last) {
// returns a random number in the range [first, last]
int diff;
diff = (last - first) + 1;
return rand() % diff + first;
}