Thread: question

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    73

    question

    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;
    				}
    			}
    		}
    	}

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Code:
    int main ()
    {
    return 0;
    }
    Spot the reason why your program doesnt do much

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM