#define, on 22 March 2013 - 05:46 PM, said:
By iteration I mean once time through the loop. Iteration
You could try printing the values in the loop :
You could try printing the values in the loop :
for (int rowTaken = ROWS; rowTaken >0 ; rowTaken--)
{
cout << "rowTaken : " << rowTaken << " localRowVariable : " << localRowVariable << endl;
when i do this is what i get. i seriously have no idea why, i tried following it in code but i dont understand why the localRowVariable is being output twice. this is what i get
Column choices are 0 - 5
What column do you want to Place your piece: 3
rowTaken : 7 localRowVariable : 7
rowTaken : 6 localRowVariable : 6
rowTaken : 5 localRowVariable : 6
rowTaken : 4 localRowVariable : 5
rowTaken : 3 localRowVariable : 5
rowTaken : 2 localRowVariable : 4
rowTaken : 1 localRowVariable : 4
0 1 2 3 4 5
|-----------------------|
| | | | | | |
|-----------------------|
| | | | | | |
|-----------------------|
| | | | | | |
|-----------------------|
| | | | | | |
|-----------------------|
| | | | U | | |
|-----------------------|
| | | | U | | |
|-----------------------|
| | | | U | | |
|-----------------------|
I changed it back so the code is more "readable" (goes with what is happening)
// start at the bottom of the board and loop until an empty spot is found
for (int rowTaken = ROWS; rowTaken > 0; rowTaken--)
{
cout << "rowTaken : " << rowTaken << " localRowVariable : " << localRowVariable << endl;
//if the spot is empty place the user piece 'U' in that spot
if (GameBoard[localRowVariable][columnNum] == EMPTY)
{
GameBoard[localRowVariable][columnNum] = USER;
}
// otherwise decrement the row variable until and empty one is found
else
{
localRowVariable--;
}
// cout << "rowTaken : " << rowTaken << " localRowVariable : " << localRowVariable << endl;
}

New Topic/Question
Reply





MultiQuote




|