Why won't my program work

I'm trying to write a program, where two people can play tic-tac-toe. I've gotten the program to work, up until the part, where it determines if the game is over, when someone wins... program thus far is posted below. I just can't figure out how to solve/finish it :(. Code is posted below. Any tips?






#include <iostream>
using namespace std;

int main()
{
int board[3][3],x,y,loopcount=0;
int PlayerA=1, PlayerB=5;
int i=0;
int winchecker=0, checkx=0, checky=0;



while(true)
{
i++;
//to set board
for (y=0;y<3; y++)
{
cout<<endl;
for (x=0;x<3; x++)
{
if (loopcount==0) {board[x][y]=0;}
cout<<board[x][y]<<"\t";
}
}
//
cout<<endl;



//game play
{
do{
if ((i % 2)!=0) {cout<<"Player A\n";}
else {cout<<"Player B\n";}
cin>>x; cin>>y;
if ((x>2 or x<0) or (y>2 or y<0) or (board[x][y]!=0)){cout<<"Error\n";}
if (board[x][y]==0)
{
if ((i % 2)!=0) {board[x][y]=PlayerA;}
else {board[x][y]=PlayerB;}
}
else {x=5;}



// to determine winner

while (checkx<3)
{

winchecker+=board[checkx][checky];
cout<<winchecker<<"\n";
checky++;
if (winchecker==(3*PlayerA) or winchecker==(3*PlayerB)) {cout<<"Winner"; break;}

if (checky>2)
{
checky=0;
checkx++;
winchecker=0;
}

}
checkx=0;checky=0;






}while((x>2 or x<0) or (y>2 or y<0));
}











cout<<endl;
loopcount++;
}


}
[/code]
Topic archived. No new replies allowed.