greeter

shuffle array elements (assumes 52 integers stored in array)

Nov 3rd, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. void shuffle(int a) {
  2.     int temp = 0, counter_deck = 0, counter_do_loop = 0, exchange_rand = 0, exchange_card = 0;
  3.     for (counter_do_loop = 0; counter_do_loop < a; counter_do_loop++) {
  4.         for (counter_deck = 0; counter_deck < 52; counter_deck++) {
  5.             temp = cards[counter_deck];
  6.             exchange_rand = (rand() % 52);
  7.             exchange_card = cards[exchange_rand];
  8.             cards[counter_deck] = cards[exchange_card];
  9.             cards[exchange_card] = temp;
  10.         }}
  11.     return;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment