Is it possible to randomly output all elements of an array with a loop?
like lets say we have a loop and array:
arrayCount = 10
int array [10] = {1, 2,2, 3,3,3, 4,4,4,4}
for (int i = 0; i < arrayCount; i++)
{
int x = Random(array);
}
obviously my loop code is wrong. But is it possible to output every element randomly (no repeats unless the element appears multiple times i.e. output four 4's but not five times) through a loop function?
Also I'd like to know if there is an easier way to make an array with repeated elements of varying degrees like the above example or should I just do it manually and write out the array. i.e. how to make an array with one 1, three 2's, three 3's, six 4's, two 5's without just typing out every element. Preferably because I'd like to be able to adjust the frequency each number appears.