Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. int main()
  5. {
  6. int t[9] = {'1','2','3','4','5','6','7','8','9'};
  7. int turn = 0;
  8. while(1)
  9. {
  10.  
  11. printf("\n\n\n\n\n%c %c %c\n%c %c %c\n%c %c %c\n",t[0], t[1],t[2], t[3], t[4],t[5],t[6], t[7],t[8]);
  12. if((t[0] == t[1] && t[1] == t[2]) || (t[3] == t[4] && t[4] == t[5]) || (t[6] == t[7] && t[7] == t[8]) ||(t[0] == t[3] && t[3] == t[6]) || (t[1] == t[4] && t[4] == t[7]) || (t[2] == t[5] && t[5] == t[8])|| (t[0] == t[4] && t[4] == t[8])|| (t[2] == t[4] && t[4] == t[6]) )
  13. {
  14. printf("Game over");
  15. break;
  16. }
  17.  
  18. if(turn%2==0)
  19. printf("X's turn ");
  20. else
  21. printf("O's turn ");
  22. int mo;
  23. scanf("%d",&mo);
  24. if(turn%2==0)
  25. t[mo - 1] = 'X';
  26. else
  27. t[mo - 1] = 'O';
  28. turn++;
  29.  
  30. }
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement