So first off, your
is using an integer argument that hasn't been initialized; you meant to pass
Second, your prototype for
void my_shuffle(int a, int n);
differs from your definition:
void my_shuffle(int a)
for (int i = n - 1; i > 0; i--)
my_swap(a[rand() % (i + 1)], a[i]);
noticing the missing
in the definition that is supposed to hold the array size.
Third, I'm assuming in your
definition, when you're using
, you want to switch a random element within the array with the current element being looked at. The correct code looks like:
[rand() % n]
You're selecting an index at a random location from 0 - 9 (size of array).
Fourth, you have a redefinition of
, instead of simply passing
as a parameter.
Fifth, you have an un-used variable
Sixth, without a seed value - the random number is pseudo-random, meaning that each time you run the program you'll get the same results. I added
to fix that.
You may want to revisit declaring functions and passing arguments.