#include <stdio.h>
#include <stdbool.h>
#include <ctype.h>


bool x_win_status(char table[]){

if (table[1] == 'X' && table[2] == 'X' && table[3] == 'X')
	return true;

if (table[4] == 'X' && table[5] == 'X' && table[6] == 'X')
	return true;

if (table[7] == 'X' && table[8] == 'X' && table[9] == 'X')
	return true;

if (table[1] == 'X' && table[4] == 'X' && table[7] == 'X')
	return true;

if (table[2] == 'X' && table[5] == 'X' && table[8] == 'X')
	return true;

if (table[3] == 'X' && table[6] == 'X' && table[9] == 'X')
	return true;

if (table[1] == 'X' && table[5] == 'X' && table[9] == 'X')
	return true;

if (table[3] == 'X' && table[5] == 'X' && table[7] == 'X')
	return true;

else
	return false;
}



bool y_win_status(char table[]){

if (table[1] == 'Y' && table[2] == 'Y' && table[3] == 'Y')
	return true;

if (table[4] == 'Y' && table[5] == 'Y' && table[6] == 'Y')
	return true;

if (table[7] == 'Y' && table[8] == 'Y' && table[9] == 'Y')
	return true;

if (table[1] == 'Y' && table[4] == 'Y' && table[7] == 'Y')
	return true;

if (table[2] == 'Y' && table[5] == 'Y' && table[8] == 'Y')
	return true;

if (table[3] == 'Y' && table[6] == 'Y' && table[9] == 'Y')
	return true;

if (table[1] == 'Y' && table[5] == 'Y' && table[9] == 'Y')
	return true;

if (table[3] == 'Y' && table[5] == 'Y' && table[7] == 'Y')
	return true;

else
	return false;
}


int main() {
printf("welcome to tic tac toe game!\n");
printf("rules are simple and you know it already just use X/Y for players\n");
int box_choice;
int count = 0;
char new_value;
char table[11] = {'0','1','2','3','4','5','6','7','8','9','\0'};
printf("%c | %c | %c\n",table[1],table[2],table[3]);
printf("%c | %c | %c\n",table[4],table[5],table[6]);
printf("%c | %c | %c\n", table[7],table[8],table[9]);
do {
printf("choose number you want to mainpulate on table\n");
scanf("%d", &box_choice);
printf("choose new value X/Y\n");
scanf(" %c", &new_value);
char uppercase_new_value = toupper(new_value);
count++;
table[box_choice] = uppercase_new_value;

printf("%c | %c | %c\n",table[1],table[2],table[3]);
printf("%c | %c | %c\n",table[4],table[5],table[6]);
printf("%c | %c | %c\n", table[7],table[8],table[9]);

} while ((x_win_status(table) == false && y_win_status(table) == false) && count !=9);

if (!(x_win_status(table) == false && y_win_status(table) == false)){


printf("we have a winner!\n");
}

else {
	printf("thats a draw\n");
}
return 0;
}