tic tac toe

Hello!
So in my C++ class we've just finished arrays and we got a rather interesting challenge. In this challenge, we're supposed to write a program that allows two players to play tic tac toe by starting with a 3x3 board of asterisks which fills up as each player makes his/her choice until one player wins or the game is completed.
I've been able to figure out simpler things like initializing and displaying the game board, accepting the user input in turns, validating user input, and using the input to change the board. The only real thing I'm having a problem with is figuring out a function to check if the game has been won already, without just having a super long and drawn out function checking each combination of possible wins. Even then, it would be difficult to do.
I've written out most the code, but having realized that my first-conceived method of checking for a winner wouldn't work, I'm scrapping most of it. I can post it later if anyone thinks it might help, but I don't think it'll really help that much.

Thanks for the help.
if you have a 2 dimensional array you can check it like so:

1
2
3
4
5
if((a[0][0] == a[1][0]) && (a[0][0] == a[2][0]))
  // The first horizontal line won
else if((a[0][1] == a[1][1]) && (a[0][1] == a[2][1]))
  // The secon horizontal line won
// you get the flow... 


Not much different in vertical or diagonal. You might put that in a loop
Topic archived. No new replies allowed.