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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#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;
}
| |