Guest User

Untitled

a guest
Apr 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. int twoDice();
  7.  
  8. int twoDice()
  9. {
  10.     int sum, n1, n2;
  11.  
  12.     n1 = rand() % 6 + 1;
  13.     n2 = rand() % 6 + 1;
  14.     sum = n1 + n2;
  15.     return sum;
  16. }
  17.  
  18. int main()
  19. {
  20.     int seed = time(0);
  21.     srand(seed);
  22.     int c[13] = {0};
  23.     int sum;
  24.    
  25.     for(int i = 1; i <= 60; i++)
  26.     {
  27.         sum = twoDice();
  28.         c[sum]++;
  29.     }
  30.  
  31.     for(int i = 2; i <= 12; i++)
  32.     {
  33.         cout << "c[" << i << "] = " << c[i] << endl;
  34.     }
  35.  
  36.    
  37.  
  38.     return 0;
  39. }
Add Comment
Please, Sign In to add comment