It'd be easier to just have a single array of 52 cards, then you can say
for (int i=0; i<52; i++)
for (int j=i+1; j<52; j++)
Now j
will always be higher than i
, so you get no repeats. You could do a similar thing for the 2-d array, but it's a bit trickier:
for (int k=i; ...)
for (int l=j+1; ...)
in the inner two loops ought to do it.
tzaman
2010-05-11 08:40:14