Tic-Tac-Toe program

I have a project where I have to create a tic tac toe game with a computer AI. The AI isn't really an AI, as we have to create 3 different scenarios in which the computer reacts to win, block, or make a "smart" move


to make the board of the game, the user has to enter 9 integers from 0-2 to create the positions, for example, if the user enters:

1,1,0,2,0,0,2,0

the board created would show as:

+-+-+-+
|1|1|0|
+-+-+-+
|2|0|0|
+-+-+-+
|0|2|0|

as you can see, the integers the user inputs are arranged from left to right


My question is, my professor wants me to use one variable to represent the 0-2 integer positions, how could i construct this? cannot use arrays
There are several options, depending on your level of C++. I will mention here a few:
1. Equivalent to arrays, you can use a pointer
2. You can use a string "11020020"
3. You can use a vector from the standard library
4. A little bit of thinking: you can store that as an integer: 1*3^0+1*3^1+0*3^2+2*3^3+...
This link might be useful;http://www.wikihow.com/Win-at-Tic-Tac-Toe
It shows what moves must somebody do to win always a game of tic tac toe. You can apply them with "if" statements in your code.
Topic archived. No new replies allowed.