Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- int twoDice();
- int twoDice()
- {
- int sum, n1, n2;
- n1 = rand() % 6 + 1;
- n2 = rand() % 6 + 1;
- sum = n1 + n2;
- return sum;
- }
- int main()
- {
- int seed = time(0);
- srand(seed);
- int c[13] = {0};
- int sum;
- for(int i = 1; i <= 60; i++)
- {
- sum = twoDice();
- c[sum]++;
- }
- for(int i = 2; i <= 12; i++)
- {
- cout << "c[" << i << "] = " << c[i] << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment