Thursday, July 9, 2009

C programming?

This is in c not c++ or c#. If ive shuffled a deck of cards how do i deal the cards. seven to the user and seven to the computer. My deck is a 2d string using ascii code for the deck. If anyone can help id appreciate it

C programming?
I would probably have another 2D bit array initialized to '0' which means that nothing has been dealt.





To deal, generate 2 random numbers which are bounded by the 2D string boundaries. The two numbers will correspond to the array position of a card. Ex: 7, 1 StringArray(7)(1)





If the bit array position is marked 0, then deal that corresponding card to a player and mark 1 in that position of the bit array.


If the bit array position ois marked 1, then generate keep generating 2 random numbers until 0 is found in the bit array.





I'm guessing you know how to handle the players hands, maybe another array?





Anyway, hope that helped.


No comments:

Post a Comment