It's pretty close to what I had done, it is sometimes hard to follow flowcharts. (Making complicated ones is hard too.)
In the flowchart, see how the flow of control goes back to the if statement if the second condition is false? That makes the first "if" a loop. So it's really a "while" statement instead of an "if."
1 2 3 4 5 6 7 8
|
int conditionOfSomeKind = 0;
while( condition is true ) {
do something in here.
Increment conditionOfSomeKind.
}
| |
You also need to initiate row & col to 0 on lines 14 & 15.
I like using the "for" loop because it lets me keep everything together:
1 2 3 4 5
|
for(variable initialization; condition; increment variable ) {
do something in here
}
| |
So for the rows and columns you can do something like this:
1 2 3 4 5 6 7 8 9 10
|
for(int row = 0; row < ROW; row++) {
if(board[row][0] == player && board[row][1] == player && board[row][2] == player){
hasWon = 1; // You could a bool variable here or a char and assign it the winner's symbol.
break; // This ends the loop. Since we found three in a row, we don't need to check the other rows.
}
}
| |
On lines 54-56 you have if the spot is empty, fill it with player's symbol. You can add an else statement there for the "Already taken!" message.
On line 85, you have "while(true);" I'm pretty sure this is where you want "count <=9", you can delete line 83. You'll want to make a count variable and set it to 0 somewhere with the rest of the variables declared in the beginning of the code. After all nine turns are taken, we want to do something depending if there's a winner or if it's a draw. (I'd delete the extra bracket on line 87-89, probably going to give you a syntax error.)
Have you thought about using functions yet? There's some documentation on functions on the site here:
http://www.cplusplus.com/doc/tutorial/functions/ (at the bottom of the page there's a "next" button for the second half.) You can always ask us if you need help implementing functions.