int array[52];
for(i=0;i<52;++i)
{
int rand=rand()%52;
swap(a[i],a[rand]);
}On Sat, Jun 26, 2010 at 8:35 PM, Anil C R <[email protected]> wrote: > I'm assuming that the random function can generate uniformly distributed > random numbers between 0 and n(excluding n), where n is an +ive integer. > > def randperm( A ): > for i in range(0, n): > t = i+1 + random(, n - i-1 ) > swap(A[t], A[i]) > > note that the permutation is in-place. > > Anil > > > > On Sat, Jun 26, 2010 at 4:55 PM, sharad kumar <[email protected]>wrote: > >> Write a method to shufle the deck. The constraint is it has to be a >> perfect shuffle - in other words, every 52! permutations of the deck has to >> be equally like (given a completely random function which is theoretical of >> course) >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<algogeeks%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<algogeeks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- yezhu malai vaasa venkataramana Govinda Govinda -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
