Skip to content

Instantly share code, notes, and snippets.

@zsrinivas
Created June 14, 2014 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zsrinivas/ea9a9d8f1b0cddf43ec9 to your computer and use it in GitHub Desktop.
Save zsrinivas/ea9a9d8f1b0cddf43ec9 to your computer and use it in GitHub Desktop.
void swap(int *p,int *q)
{
int temp;
temp=*p;
*p=*q;
*q=temp;
}
void shuffle(int *data,int size)
{
int i,j;
srand(time(NULL));
for (i = 0; i < size-1; ++i)
{
j=rand()%(size-i) + i;
swap(data+i,data+j);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment