Can anyone help me. I have a bit of code that i need for my next project (anouther damn tic tac toe project) but I can't seem to get it to work. This is the code my teacher gave in class so its right. All I need to know is how to define the varibles. I tried defining them all differant kinds of ways but i still get error messages. Heres my code. If someone could compile it and tell me how to fix it that would be great.
Code:
#include <iostream>
#include <string>
using namespace std;
bool safe(int);
void nth_nextgame(int,int,int);
int main ()
{
return 0;
}
void nth_nextgame (int n, int gamestate[9], int nextgame[9])
{
for (int i=0; i<9; i++)
{
if (i<number_of_moves(gamestate))
nextgame[i]=gamestate[i];
else
if (i==number_of_moves(gamestate))
nextgame[i]=nth_nextgame(n,gamestate);
else
nextgame[i]=-1;
}
}
bool safe (int gamestate[9])
{
//o's move only!!!!!!
bool safeflag=false;
num_of_suc=9-number_of_moves(gamestate);
int nextgame[9];
if (number_of_moves(gamestate)%2==1)
{
for (int i=1; i<=numofsuc; i++)
{
nth_nextgame(i, gamestate, nextgame);
if (safe(nextgame))
safeflag=true;
}
}
else
{
bool safeflag=true;
if (number_of_moves(gamestate)%2==1)
{
for (int i=1; i<=numofsuc; i++)
{
nth_nextgame(i, gamestate, nextgame);
if (!safe(nextgame))
safeflag=false;
}
}
}
}