Code:
#include <stdio.h>
#include <time.h>
int getCurrent( int c[], int num )
{
int x,y,z;
for( y = -1, x = 0; x < 52; x++ )
{
if( c[x] > -1 ) y++;
if( y == num )
{
y = c[x];
c[x] = -1;
return y;
}
}
return -1;
}
int main( void )
{
int cards[52], deck[52], count, current;
srand( time(0) );
for( count = 0; count < 52; count++ )
{
cards[count] = count;
}
for( count = 0, current=52; count++ )
{
deck[count] = getCard( card, rand() % current-- );
if( deck[count] == -1 )
{
error...exit or do whatever, shouldn't ever happen
}
}
}
I'm sure this is your homework assignment, but I'm tired, and don't care. You luck out today. Anyway, this should work. I haven't tried it, and keep in mind I've only had 2 hours sleep in the past day, so use at your own risk.
Quzah.