cout<<"Wpisz wspolrzedne X oraz Y odzielajac je spacja.\n\n"; cin >>x; cin >>y; x=x-1; y=y-1; i=0; j=-1; l=-1; k=0;
do { j=j+1; l=l+1; if (j==4) {j=0;} if (l==4) {k=k+1;l=0;}
if (x==j && y==k && move[j][k]=="X") { cout << "To miejsce jest juz zajete\n\n";} else {if (x==j && y==k && move[j][k]=="O") {cout << "To miejsce jest juz zajete\n\n";} else{if (x==j && y==k) {move[j][k]=turn; cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; if (turn=="X") {turn="O";} else{turn="X";}}}} i=i+1;
} while (i<11);
//Win conditions //Rows if (move[0][0]=="X" && move[0][1]=="X" && move[0][2]=="X") {win="X"; end=15;} if (move[1][0]=="X" && move[1][1]=="X" && move[1][2]=="X") {win="X"; end=15;} if (move[2][0]=="X" && move[2][1]=="X" && move[2][2]=="X") {win="X"; end=15;}
if (move[0][0]=="O" && move[0][1]=="O" && move[0][2]=="O") {win="O"; end=15;} if (move[1][0]=="O" && move[1][1]=="O" && move[1][2]=="O") {win="O"; end=15;} if (move[2][0]=="O" && move[2][1]=="O" && move[2][2]=="O") {win="O"; end=15;} //colom if (move[0][0]=="X" && move[1][0]=="X" && move[2][0]=="X") {win="X"; end=15;} if (move[0][1]=="X" && move[1][1]=="X" && move[2][1]=="X") {win="X"; end=15;} if (move[0][2]=="X" && move[1][2]=="X" && move[2][2]=="X") {win="X"; end=15;}
if (move[0][0]=="O" && move[1][0]=="O" && move[2][0]=="O") {win="O"; end=15;} if (move[0][1]=="O" && move[1][1]=="O" && move[2][1]=="O") {win="O"; end=15;} if (move[0][2]=="O" && move[1][2]=="O" && move[2][2]=="O") {win="O"; end=15;} //diagnals if (move[0][0]=="X" && move[1][1]=="X" && move[2][2]=="X") {win="X"; end=15;} if (move[0][2]=="X" && move[1][1]=="X" && move[2][0]=="X") {win="X"; end=15;}
if (move[0][0]=="O" && move[1][1]=="O" && move[2][2]=="O") {win="O"; end=15;} if (move[0][2]=="O" && move[1][1]=="O" && move[2][0]=="O") {win="O"; end=15;}
} while (end<9);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; if (win=="X") {cout << "Gracz X wygral\n\n";} if (win=="O") {cout << "Gracz O wygral\n\n";} else if (win=="A"){cout<<"Remis\n\n";}
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int end;
int x,y;
string move[3][3];
int i,j,l,k;
i=0;j=-1;l=-1;k=0;
string turn ("X");
end=0;
string win;
win="A";
do {
move[0][0]=" ";move[0][1]=" ";move[0][2]=" ";move[1][0]=" ";move[1][1]=" ";move[1][2]=" ";move[2][0]=" ";move[2][1]=" ";move[2][2]=" ";
end=0;
win="A";
do {
cout<<"Turn: "<<turn<< "\n\n";
cout << " | | \n";
cout << " "<<move[0][0]<<" | "<<move[0][1]<<" | "<<move[0][2]<<" \n";
cout << "____|____|____ \n";
cout << " | | \n";
cout << " "<<move[1][0]<<" | "<<move[1][1]<<" | "<<move[1][2]<<" \n";
cout << "____|____|____ \n";
cout << " | | \n";
cout << " "<<move[2][0]<<" | "<<move[2][1]<<" | "<<move[2][2]<<" \n";
cout << " | | \n\n";
cout<<"Wpisz wspolrzedne X oraz Y odzielajac je spacja.\n\n";
cin >>x;
cin >>y;
x=x-1;
y=y-1;
i=0;
j=-1;
l=-1;
k=0;
do {
j=j+1;
l=l+1;
if (j==4) {j=0;}
if (l==4) {k=k+1;l=0;}
if (x==j && y==k && move[j][k]=="X") { cout << "To miejsce jest juz zajete\n\n";}
else {if (x==j && y==k && move[j][k]=="O") {cout << "To miejsce jest juz zajete\n\n";} else{if (x==j && y==k) {move[j][k]=turn; cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
if (turn=="X") {turn="O";}
else{turn="X";}}}}
i=i+1;
} while (i<11);
//Win conditions
//Rows
if (move[0][0]=="X" && move[0][1]=="X" && move[0][2]=="X") {win="X"; end=15;}
if (move[1][0]=="X" && move[1][1]=="X" && move[1][2]=="X") {win="X"; end=15;}
if (move[2][0]=="X" && move[2][1]=="X" && move[2][2]=="X") {win="X"; end=15;}
if (move[0][0]=="O" && move[0][1]=="O" && move[0][2]=="O") {win="O"; end=15;}
if (move[1][0]=="O" && move[1][1]=="O" && move[1][2]=="O") {win="O"; end=15;}
if (move[2][0]=="O" && move[2][1]=="O" && move[2][2]=="O") {win="O"; end=15;}
//colom
if (move[0][0]=="X" && move[1][0]=="X" && move[2][0]=="X") {win="X"; end=15;}
if (move[0][1]=="X" && move[1][1]=="X" && move[2][1]=="X") {win="X"; end=15;}
if (move[0][2]=="X" && move[1][2]=="X" && move[2][2]=="X") {win="X"; end=15;}
if (move[0][0]=="O" && move[1][0]=="O" && move[2][0]=="O") {win="O"; end=15;}
if (move[0][1]=="O" && move[1][1]=="O" && move[2][1]=="O") {win="O"; end=15;}
if (move[0][2]=="O" && move[1][2]=="O" && move[2][2]=="O") {win="O"; end=15;}
//diagnals
if (move[0][0]=="X" && move[1][1]=="X" && move[2][2]=="X") {win="X"; end=15;}
if (move[0][2]=="X" && move[1][1]=="X" && move[2][0]=="X") {win="X"; end=15;}
if (move[0][0]=="O" && move[1][1]=="O" && move[2][2]=="O") {win="O"; end=15;}
if (move[0][2]=="O" && move[1][1]=="O" && move[2][0]=="O") {win="O"; end=15;}
} while (end<9);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
if (win=="X") {cout << "Gracz X wygral\n\n";}
if (win=="O") {cout << "Gracz O wygral\n\n";}
else if (win=="A"){cout<<"Remis\n\n";}
getchar();
getchar();
} while (end<100);
}