You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int b[10] = {2,2,2,2,2,2,2,2,2,2};
int t = 1,f = 0;
int p,c;
void menu();
void go(int n);
void start_game();
void check_draw();
void draw_board();
void player_first();
void put_X_O(char ch,int pos);
COORD coord= {0,0}; // this is global variable
//center of axis is set to the top left cornor of the screen
void gotoxy(int x,int y)
{
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
void main()
{
system("cls");
menu();
getch();
}
void menu()
{
int choice;
system("cls");
printf("\n--------MENU--------");
printf("\n1 : Play with X");
printf("\n2 : Play with O");
printf("\n3 : Exit");
printf("\nEnter your choice:>");
scanf("%d",&choice);
t = 1;
switch (choice)
{
case 1:
p = 1;
c = 0;
player_first();
break;
case 2:
p = 0;
c = 1;
start_game();
break;
case 3:
exit(1);
default:
menu();
}
}
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include <windows.h>
int b[10] = {2,2,2,2,2,2,2,2,2,2};
int t = 1,f = 0;
int p,c;
void menu();
void go(int n);
void start_game();
void check_draw();
void draw_board();
void player_first();
void put_X_O(char ch,int pos);
COORD coord= {0,0}; // this is global variable
//center of axis is set to the top left cornor of the screen
void gotoxy(int x,int y)
{
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
void main()
{
system("cls");
menu();
getch();
}
void menu()
{
int choice;
system("cls");
printf("\n--------MENU--------");
printf("\n1 : Play with X");
printf("\n2 : Play with O");
printf("\n3 : Exit");
printf("\nEnter your choice:>");
scanf("%d",&choice);
t = 1;
switch (choice)
{
case 1:
p = 1;
c = 0;
player_first();
break;
case 2:
p = 0;
c = 1;
start_game();
break;
case 3:
exit(1);
default:
menu();
}
}
int make2()
{
if(b[5] == 2)
return 5;
if(b[2] == 2)
return 2;
if(b[4] == 2)
return 4;
if(b[6] == 2)
return 6;
if(b[8] == 2)
return 8;
return 0;
}
int make4()
{
if(b[1] == 2)
return 1;
if(b[3] == 2)
return 3;
if(b[7] == 2)
return 7;
if(b[9] == 2)
return 9;
return 0;
}
int posswin(int p)
{
// p==1 then X p==0 then O
int i;
int check_val,pos;
}
void go(int n)
{
if(t % 2)
b[n] = 3;
else
b[n] = 5;
turn++;
}
void player_first()
{
int pos;
}
void start_game()
{
// p==1 then X p==0 then O
if(posswin(c))
{
go(posswin(c));
f = 1;
}
else if(posswin(p))
go(posswin(p));
else if(make2())
go(make2());
else
go(make4());
draw_board();
}
void check_draw()
{
if(turn > 9)
{
gotoxy(30,20);
//textcolor(128+RED);
printf("Game Draw");
getch();
exit(0);
}
}
void draw_board()
{
int j;
}
void put_X_O(char ch,int pos)
{
int m;
int x = 31, y = 10;
}
The text was updated successfully, but these errors were encountered: