a logic problem?
Posted: Mon Sep 15, 2003 9:24 pm
I have a problem not know how to handle, say I have a tic tac toe game, which is like
How can I use a nested for loop to check whether each player win the game, here is part what I do so far:
the above logic should be wrong, I have no idea how to build the logic to use nested loops solve the problem, can anybody tell me how to figur it out?
Code: Select all
XXO
OOX
OOXCode: Select all
for($i=0; $i<3; $i++)
{
for($j=0; $j<3; $j++)
{
if($gridї$i]ї$j] == "X")
{
print("Player1 win");
}
else if($gridї$i]ї$j] == "O")
{
print("Player2 win");
}
}
}