C
c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//creator: Rooney
#include <stdio.h>
#include <stdbool.h>
#define size 9
void display(char board[])
{
for(int i = 0; i < size; i += 3)
{
printf(" %c | %c | %c\n", board[i], board[i + 1], board[i + 2]);
if(i < 6) printf("---+---+---\n");
}
}
bool checkWin(char board[], char player)
{
int conditions[8][3] = {
{0, 1, 2}, {3, 4, 5}, {6, 7, 8},//horizontal
{0, 3, 6}, {1, 4, 7}, {2, 5, 8},//vertical
{0, 4, 8}, {2, 4, 6}//diagonal
};
for(int i = 0; i < 8; i++)
{
if(board[conditions[i][0]] == player && board[conditions[i][1]] == player && board[conditions[i][2]] == player) return true;
}
return false;
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run