Advertisement
Tarche

DosDados

Jun 22nd, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <time.h>
  4. #include <stdlib.h>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.     int num1, num2, suma;
  10.     const int cotaSuperior=12;
  11.     const int cotaInferior=2;
  12.     vector<int> tiradas(cotaSuperior + 1);
  13.     srand(time(NULL));
  14.     for(int i=0; i<700;i++) {
  15.         for (int j = 0; j < 10; j++) {
  16.             num1 = rand() % (cotaSuperior / 2 - cotaInferior / 2 + 1) + cotaInferior / 2;
  17.             num2 = rand() % (cotaSuperior / 2 - cotaInferior / 2 + 1) + cotaInferior / 2;
  18.             suma = num1 + num2;
  19.             cout << suma << '\n';
  20.             tiradas[suma]++;
  21.         }
  22.         cout << '\n';
  23.     }
  24.  
  25.     cout << "\n\n\n\n";
  26.  
  27.     for (int i = cotaInferior; i <= cotaSuperior; i++) {
  28.         cout << "La cantidad de veces que la suma de los dados dio " << i << " es: " << tiradas[i] << "\n";
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement