#include<iostream>
#include<conio.h>
using namespace std;
char square[10] = {'o','1','2','3','4','5','6','7','8','9'};
void box();
int checkwin();
int main()
{
char f, g, e[10]={'o','1','2','3','4','5','6','7','8','9'};
int a;
int c, d;
for(a=1;(a<=9);a++)
{
int b;
system("CLS");
box();
if(a%2==1)
{
cout<<"player 1 enter your num\n";
cin>>b;
}
else
{
cout<<"player 2 enter you number\n";
cin>>c;
}
if(b==1&&square[1]=='1')
square[1]='X';
else if(b==2&&square[2]=='2')
square[2]=='X';
else if(c==1&&square[1]=='1')
square[1]='O';
}
getch();
return 0;
}
void box()
{
system("CLS");
cout << "\n\n\tTic Tac Toe\n\n";
cout << "Player 1 (X) - Player 2 (O)" << endl << endl;
cout << endl;
cout << " | | " << endl;
cout << " " << square[1] << " | " << square[2] << " | " << square[3] << endl;
cout << "_____|_____|_____" << endl;
cout << " | | " << endl;
cout << " " << square[4] << " | " << square[5] << " | " << square[6] << endl;
cout << "_____|_____|_____" << endl;
cout << " | | " << endl;
cout << " " << square[7] << " | " << square[8] << " | " << square[9] << endl;
cout << " | | " << endl << endl;
}
i was working on tic tac toe, but i am stuck in the middle..
if you compiler, when player 1 presses 2, nothing happens....but works fine when you press 1....why the conditions after the first condition, not working!!