0
How can I generate random numbers in a array without each one of them repeating?
card game
3 Réponses
+ 1
You could just generate a new random number, if it's already in the array... or use a set. This way it would already be sorted.
0
I mean lyk it it must not print 2334
0
#include <algorithm>
...
int arr[] { 1,2,3,4,5 };
unsigned len = sizeof(arr)/sizeof(arr[0]);
std::random_shuffle(&arr[0], &arr[len - 1];
// Now it is shuffled.