-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek4.cpp
More file actions
42 lines (38 loc) · 834 Bytes
/
Copy pathweek4.cpp
File metadata and controls
42 lines (38 loc) · 834 Bytes
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
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
int RandomInt(int first, int last);
int i, x, a, b, c, d, e, f, result;
int main () {
for(i = 0; i < 6000; i++){
x = RandomInt(1, 6);
if(x == 1){
a = a + 1;
}
else if(x == 2){
b = b + 1;
}
else if(x == 3){
c = c + 1;
}
else if(x == 4){
d = d + 1;
}
else if(x == 5){
e = e + 1;
}
else if(x == 6){
f = f + 1;
}
}
cout << a << endl<< b << endl << c << endl << d << endl << e << endl << f << endl;
result = a + b + c + d + e + f;
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;
}