-1

So, I can't search what the meaning of this let say for example I have

    string TICTACTOE[3][3] = {
        {"1","2","3"}, 
        {"4","5","6"}, 
        {"7","8","9"}
    };

How can I make boolean passing the condition statement in something like this

    bool trial = TICTACTOE[0][0] == TICTACTOE[0][1] == TICTACTOE[0][2]
     if (trial) {
         cout << "THIS PLAYER WINS: " <<playerWinner << endl;
    }

Its working though if its only

bool trial = TICTACTOE[0][0] == TICTACTOE[0][1]

but when its three bool its not working..anyone can explain me this? I'm just used to do with it "==" since I used to use javascript a lot.

Myth Vince
  • 143
  • 9

1 Answers1

1

You can do this

int check()
{
    if (a[1] == a[2] && a[2] == a[3])       return 1;  //GAME IS OVER WITH RESULT
    else if (a[4] == a[5] && a[5] == a[6])  return 1;
    else if (a[7] == a[8] && a[8] == a[9])  return 1;
    
    else if (a[1] == a[4] && a[4] == a[7])  return 1;
    else if (a[2] == a[5] && a[5] == a[8])  return 1;
    else if (a[3] == a[6] && a[6] == a[9])  return 1;
    
    else if (a[1] == a[5] && a[5] == a[9])  return 1;
    else if (a[3] == a[5] && a[5] == a[7])  return 1;
    
    if ( a[1] != '1' && a[2] != '2' && a[3] != '3' && a[4] != '4' && 
         a[5] != '5' && a[6] != '6' && a[7] != '7' && a[8] != '8' && a[9] != '9')
                      return 0;              //GAME IS OVER AND NO RESULT
    else
        return -1;   //GAME IS IN PROGRESS
}
Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
charon
  • 11
  • 2
  • 1
    Snippet markup is intended for HTML, CSS, or JavaScript. Please stop using it for other code types, it doesn’t apply here. – Blastfurnace Sep 17 '22 at 19:59