Tic Tac Toe game help
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#include <iostream>
using namespace std;
int main ()
{
int c;
int b;
int c1=0;
int c2=0;
int c3=0;
int c4=0;
int c5=0;
int c6=0;
int c7=0;
int c8=0;
int c9=0;
int a[]={c1, c2, c3,c4, c5, c6,c7, c8, c9};
char p1[100];
char p2[100];
cout << "player 1, enter your name: " ;
cin >> p1;
cout << "player 2, enter your name: " ;
cin >> p2;
cout << "Welcome to tic tac toe: "<< endl;
cout << "1|2|3" << endl;
cout << "4|5|6" << endl;
cout << "7|8|9" << endl;
for (int x=0;x<10;x++) {
do {cout << p1 << " your turn,choose a case: " << endl;
cin >> c; }while (c<1||c>9||a[c]!=0);
a[c]=1;
if (c1==1 && c2==1 && c3==1) {break;
cout << p1 << " won"<< endl;}
if (c4==1 && c5==1 && c6==1) {break;
cout << p1 << " won"<< endl;}
if (c7==1 && c8==1 && c9==1) {break;
cout << p1 << " won"<< endl;}
if (c1==1 && c4==1 && c7==1) {break;
cout << p1 << " won"<< endl;}
if (c2==1 && c5==1 && c8==1) {break;
cout << p1 << " won"<< endl;}
if (c3==1 && c6==1 && c9==1) {break;
cout << p1 << " won"<< endl;}
if (c1==1 && c5==1 && c9==1) {break;
cout << p1 << " won"<< endl;}
if (c3==1 && c5==1 && c7==1) {break;
cout << p1 << " won"<< endl;}
do {cout << p2 << " your turn,choose a case: " << endl;
cin >> b; }while (b<1||b>9||a[b]!=0);
a[b]=2;
if (c1==2 && c2==2 && c3==2) {break;
cout << p2 << " won"<< endl;}
if (c4==2 && c5==2 && c6==2) {break;
cout << p2 << " won"<< endl;}
if (c7==2 && c8==2 && c9==2) {break;
cout << p2 << " won"<< endl;}
if (c1==2 && c4==2 && c7==2) {break;
cout << p2 << " won"<< endl;}
if (c2==2 && c5==2 && c8==2) {break;
cout << p2 << " won"<< endl;}
if (c3==2 && c6==2 && c9==2) {break;
cout << p2 << " won"<< endl;}
if (c1==2 && c5==2 && c9==2) {break;
cout << p2 << " won"<< endl;}
if (c3==2 && c5==2 && c7==2) {break;
cout << p2 << " won"<< endl;}}
return 0;}
|
Please help
what help?
Anyway i can give you my simple tic tac toe/
Wanna?
yes please
come in skype:
hepic.hepic
Topic archived. No new replies allowed.