58 lines
824 B
C

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<time.h>
#define CARD_MAX 51
#define len(x) sizeof(x)/sizeof(x[0])
void print_deck (int *deckOfCards);
void shuffel (int *array);
int main (int argc, char *argv[])
{
int i;
int deckOfCards[CARD_MAX];
time_t t;
srand((unsigned) time(&t));
/* Clubs > Diamonds > Hearts > Spades
* 0-12 13-25 26-38 39-51
*/
for (i = 0; i<CARD_MAX; i++){
deckOfCards[i]=i;
}
shuffel(deckOfCards);
print_deck(deckOfCards);
return 0;
}
void print_deck(int *deckOfCards){
int i;
for (i = 0; i<=CARD_MAX; i++){
printf("%d\n", deckOfCards[i]);
}
}
void shuffel (int *array){
int i, rn, a , tmp;
rn = rand();
for (i=CARD_MAX; i >= CARD_MAX/CARD_MAX ;i--){
a = rn % i;
tmp = array[a];
array[a] = array[i];
array[i] = tmp;
}
}