Tris CPP
Tris CPP
#include <cstdlib>
#include <ctime>
char X[9];
void Print();
bool Vittoria;
bool Pieno;
int main()
srand(time(0));
int p,c;
Print();
cin>>p;
X[p-1]='x';
if (Pieno==false)
c=rand()%9;
if (X[c]==' ')
while(X[c]!=' ')
c=rand()%9;
}
X[c]='o';
system("cls");
if ( X[0]!=' ' and X[1]!=' ' and X[2]!=' ' and X[3]!=' ' and X[4]!=' ' and X[5]!=' ' and X[6]!=' ' and X[7]!=' ' and
X[8]!=' ')
Pieno=true;
if (
(X[0]=X[1]=X[2]) or
(X[3]=X[4]=X[5]) or
(X[6]=X[7]=X[8]) or
(X[0]=X[3]=X[6]) or
(X[1]=X[4]=X[7]) or
(X[2]=X[5]=X[8]) or
(X[0]=X[4]=X[8]) or
(X[2]=X[4]=X[6])
Vittoria=true;
else{Vittoria=false;}
return 0;
}
void Print()
cout<<" "<<"---------\n";
cout<<" "<<"---------\n";