lots of programming classes have you deal with decks of cards. Lots of options for shuffling and managing them. It really depends on how you are using them and how you prefer to work with them... easiest way to randomize the cards is to make a second array of cards, loop through the first array and insert the card randomly into the second one inserting at a random point in the second array (aka, if you have 4 cards in the second array, you will insert the fifth element as element 0-5, when you get to the 6th element, insert it between 0-6, seventh between 0-7). This is nice if your deck is being shuffled when it is not full as you can skip empty elements. It runs in O=n time and isn't complicated. It's not a "truely random" shuffle however...
Another fun way if memory is a problem or just as an exercise, is to loop through the array of cards and swaping each card with a random card in the deck. it doesn't seem like random placement but it is (or at least close enough). this method doesn't work well if random members of the "deck" are missing when you shuffle, but is very quick and memory efficient. You can make modifications to the algorhythm to ensure the deck is "pushed' all the way to the beginning of the array very simply though.
These ways work well if you are doing something like creating a record and having it hold a suit and a rank. These "virtual decks" are fine, and intuitive, but a lot of the time it is easier to deal with a simulated card system.
Use an array of 52 bools (or even better a bit array), and simply use the mod 13 of the card for the suit, and the mod 4 of the card for the rank. When you put a card in a players hand, simply turn the bool off, and insert the array element # into the player's hand as an int. A bit rougher to get your head around, but just as simple and much lighter of a system in terms of coding. This method has it's advantages and disadvantages though.
Out of these three, I'd probably suggest the middle one... it seems the closest to what you are doing and need.
lots of programming classes have you deal with decks of cards. Lots of options for shuffling and managing them. It really depends on how you are using them and how you prefer to work with them... easiest way to randomize the cards is to make a second array of cards, loop through the first array and insert the card randomly into the second one inserting at a random point in the second array (aka, if you have 4 cards in the second array, you will insert the fifth element as element 0-5, when you get to the 6th element, insert it between 0-6, seventh between 0-7). This is nice if your deck is being shuffled when it is not full as you can skip empty elements. It runs in O=n time and isn't complicated. It's not a "truely random" shuffle however...
Another fun way if memory is a problem or just as an exercise, is to loop through the array of cards and swaping each card with a random card in the deck. it doesn't seem like random placement but it is (or at least close enough). this method doesn't work well if random members of the "deck" are missing when you shuffle, but is very quick and memory efficient. You can make modifications to the algorhythm to ensure the deck is "pushed' all the way to the beginning of the array very simply though.
These ways work well if you are doing something like creating a record and having it hold a suit and a rank. These "virtual decks" are fine, and intuitive, but a lot of the time it is easier to deal with a simulated card system. Use an array of 52 bools (or even better a bit array), and simply use the mod 13 of the card for the suit, and the mod 4 of the card for the rank. When you put a card in a players hand, simply turn the bool off, and insert the array element # into the player's hand as an int. A bit rougher to get your head around, but just as simple and much lighter of a system in terms of coding. This method has it's advantages and disadvantages though.
Out of these three, I'd probably suggest the middle one... it seems the closest to what you are doing and need.