Ways for a Perfect implementation of random numbers
I use this in my code to create a random numbers :
int main() {
srand(time(NULL));
}
int randomBetween(int start, int end) { return rand() % end + start; }
And i implement in this way to create a random array numbers :
vector <int> arrayGarbageGenerator(int size) {
vector <int> arr;
for (int i = 0; size > i; i++) arr.push_back(randomBetween(1, 50));
return arr;
}
but im not sure is this is a perfect implementation of an usage of Random, because he depends on every time when execute, a seed thats initialize the process, and when i need to create an array that contains random numbers between 0 to 50 for example (not always), the results likes a bad pattern thats doesnt gives to my function a real representation of random numbers between 0 to 50. in some cases the sequentially numbers is repeated like ... 18,2,42,42,20 ... into this array, in other cases, likes a high or low pattern values when y see the created integers inside the array.
when i need a random integers, y doesnt like to see patterns, So, my question is this : Is there any way to create a random numbers thats not resemble anything to each other (without any if else comparations) and is not like a pattern or.. this is the best to do in programmatical aplications ?
Please apologies for my bad English, for me this question likes complex and my english isnt better.
Aucun commentaire:
Enregistrer un commentaire