Shuffle



Simple and efficient algorithm to shuffle an array of integers. Pass the Array and the array size as arguments.

void shuffle(int *array, int num){
while (--num > 0){
int j = random(num);
int temp = array[num];
array[num] = array[j];
array[j] = temp;
}
}