Fandom

Scratchpad

PLE:Unidad4Ejercicio03

219,594pages on
this wiki
Add New Page
Discuss this page0 Share
/*
Programa:         Unidad4Ejercicio03.cpp
Fecha:            21/11/2006
Descripción:      Simula el lanzamiento de un dado.

*/
#include <iostream>
#include <conio>
#include <stdlib>
using namespace std;

const int NUM = 6000;
const int CARAS = 6;

void main()
{
      int cont[CARAS]= {0,0,0,0,0,0};
      int i, tmp;

      randomize();

      // Primeros lanzamos el dado NUM veces
      for(i = 0; i < NUM; i++)
      {
            tmp = random(CARAS);
            cont[tmp]++;
      }

      // Mostramos los resultados
      cout << "Resultado de la prueba de lanzamiento" << endl;
      cout << "Numero de Lanzamientos = " << NUM << endl;
      for(i = 0; i < CARAS; i++)
      {
            cout << "Cara " << i+1 << " = " << cont[i] << "\t[";
            cout << (float) cont[i]/NUM << ']' << endl;
      }


      cin.ignore();
      cin.get();
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random wikia