Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int t[9] = {'1','2','3','4','5','6','7','8','9'};
- int turn = 0;
- while(1)
- {
- 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]);
- 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]) )
- {
- printf("Game over");
- break;
- }
- if(turn%2==0)
- printf("X's turn ");
- else
- printf("O's turn ");
- int mo;
- scanf("%d",&mo);
- if(turn%2==0)
- t[mo - 1] = 'X';
- else
- t[mo - 1] = 'O';
- turn++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement