View Single Post
Old Aug 29th, 2007, 12:38 PM   #3
n3o_X
Newbie
 
Join Date: Jan 2005
Posts: 29
Rep Power: 0 n3o_X is on a distinguished road
Ok, that was my bad I was editing the code for web is all and missed that. In my code the variables are the same. The problem still occurs when the variables are correct, sorry for the messup on my end with posting the code.
Here is the code again with the typo fixed.

void myDeal()
{
             int myDeal[4][52] = {0,0};
	int p = 0;  // Player Index
	int d = 0; // Deck Index
	int card;		// Card Number (0-52)

	// Seed Random Generator
	srand((unsigned)time(NULL));

	for (d = 0; d < 52; d++)
	{
		for(p = 0; p < 4; p++)
		{

			bool result;

			do
			{
				card = rand()%52;

				if (myDeal[0][card] == 1)
					result = false;
				else if (myDeal[1][card] == 1)
					result = false;
				else if (myDeal[2][card] == 1)
					result = false;
				else if (myDeal[3][card] == 1)
					result = false;
				else
					result = true;

			}while (result == false);

			myDeal[p][card] = 1;
		}
	}
}
n3o_X is offline   Reply With Quote