Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. function WhoWon($pole) {
  2. $pionowo = array(0, 0, 0);
  3. foreach ($pole as $i) {
  4. $poziomo = 0;
  5. for ($j = 0; $j < 3; $j++) {
  6. $poziomo += $i[$j];
  7. $pionowo[$j] += $i[$j];
  8. }
  9. if ($poziomo == 3) return 1;
  10. else if ($poziomo == -3) return -1;
  11. }
  12. for ($i = 0; $i < 3; $i++) {
  13. if ($pionowo[$i] == 3) return 1;
  14. else if ($pionowo[$i] == -3) return -1;
  15. }
  16.  
  17. $skosprawo = $pole[0][0] + $pole[1][1] + $pole[2][2];
  18. if ($skosprawo == 3) return 1;
  19. else if ($skosprawo == -3) return -1;
  20.  
  21. $skoslewo = $pole[0][2] + $pole[1][1] + $pole[2][0];
  22. if ($skoslewo == 3) return 1;
  23. else if ($skoslewo == -3) return -1;
  24.  
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement