Tic - Tac - Toe

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • triphoppa
    New Member
    • Oct 2008
    • 16

    Tic - Tac - Toe

    I have to implement a tic - tac -toe game in C. The board has to be stored in an array 1D or 2D. The problem I'm having is that I don't see how I can store the game board AND the moves in the same array. This is what I have so far but, The professor wants the board and the moves stored in the same array. How can I do that? What I have below looks like "the best" way to do it. I hope I'm just misunderstandin g what he wants. Here is a link to the assignment on his webpage, click project 3 on the left side to view the assignment

    Code:
    int main(void){
        
        int row,col;
        int board[3][3] = {{1,2,3},{4,5,6},{7,8,9}};
    
    printf("\n\n");  
    printf("\t   %d |%d|%d \n",board[0][0],board[0][1],board[0][2]);
    printf("\t ----------\n");
    printf("\t   %d |%d  |%d \n",board[1][0],board[1][1],board[1][2]);
    printf("\t ----------\n");
    printf("\t   %d | %d |%d \n\n",board[2][0],board[2][1],board[2][2]);
  • curiously enough
    New Member
    • Aug 2008
    • 79

    #2
    QUICK! COPY IT BEFORE ONE OF THOSE MODERATORS DELETES IT! <swearing deleted Banfa>

    < code deleted />

    kind regards,

    Jos

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      @curiously enough: we delete spoonfeeding code because we believe that it
      doesn't help an OP; the vast majority of them simply copies/pastes the code
      and if it work they turn it in as if it were their own code. Professors complain
      about that and rightly so. We don't propagate cheating, we'd rather help people
      to learn. Nobody wants a cheater for their future coworker. If you don't agree
      with that feel free to find another forum where they do help people to cheat.

      Also in our opinion: showing off boilerplate code doesn't make you look smart;
      clear and concise explanations do and it helps the OPs (donating a fish or
      making them learn how to fish for themselves and all that).

      kind regards,

      Jos (moderator)

      Comment

      • triphoppa
        New Member
        • Oct 2008
        • 16

        #4
        Um, I guess I don't understand the culture here. I thought that I asked a viable question and I did show what I have so far. So, what's the problem? I"m not asking anyone to do it.

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by triphoppa
          Um, I guess I don't understand the culture here. I thought that I asked a viable question and I did show what I have so far. So, what's the problem? I"m not asking anyone to do it.
          Your question was perfectly valid; the spoonfeeding wasn't. Your assignment
          text doesn't mention anything about moves stored in the same array as the
          board. Line #10 reads: "The game board should be stored in an array."
          And that's what you did; no problem.

          kind regards,

          Jos

          Comment

          • Banfa
            Recognized Expert Expert
            • Feb 2006
            • 9067

            #6
            curiously enough,

            This forum tolerates neither abusive language nor posting of full code solutions all of which is explained in our posting guidelines.

            You have been warned about this several times now and are clearly purposefully flaunting our posting guidelines. Further instances of this sort of behaviour are likely to lead initially to a temporary ban of your account and if the behaviour continues after your account is re-enabled then a permanent ban.

            Banfa
            Administrator

            Comment

            • curiously enough
              New Member
              • Aug 2008
              • 79

              #7
              This forum tolerates neither abusive language nor posting of full code
              I'm sorry, I won't do either again.

              Comment

              Working...