Created
September 21, 2015 16:12
-
-
Save spceaza/351decf7e387b9ed1318 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: | |
g++ -std=c++11 -O3 -o tarea_5.bin Tarea_5.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <random> | |
#include <cmath> | |
using namespace std; | |
int main() | |
{ | |
std::random_device rd; | |
std::mt19937 e2(rd()); | |
std::uniform_int_distribution<int> dist(50,100); | |
int N, reps; | |
int * album; | |
N = dist(e2); | |
reps = dist(e2); | |
album = new int[N]{0}; | |
cout << N << endl; | |
int mean = 0; | |
std::uniform_int_distribution<int> dist2(0,N-1); | |
for(int i = 0; i < reps; i++) | |
{ | |
int iterations; | |
iterations = 0; | |
for(int control = 0; control < N; iterations++) | |
{ | |
int index; | |
index = dist2(e2); | |
if(album[index] != 1) | |
{ | |
album[index] = 1; | |
control++; | |
} | |
} | |
delete[] album; | |
album = new int[N]{0}; | |
mean += iterations; | |
} | |
mean /= reps; | |
cout << "Mean: " << mean << endl; | |
delete[] album; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment