Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- #define MILLION 1000000
- int main(void)
- {
- int chance[6] = {0};
- // seed with random time
- srand(time(NULL));
- // random number 1 - 6
- int rand_num;
- for (int i = 0; i < MILLION; i++) {
- rand_num = rand() % 6 + 1;
- chance[rand_num-1]++;
- }
- for (int i = 0; i < 6; i++) {
- cout << "probablity of " << i+1 << " is " << static_cast<double>(chance[i])/MILLION << endl;
- }
- // pause before exit
- cin.get();
- return 0;
- }
Add Comment
Please, Sign In to add comment