May 7, 2010 at 11:15am UTC
hello guys....
im working on my incomplete tictactoe game... can anyone suggest some codes to complete it?
here 's the code:
#include<iostream.h>
int tictactoe[3][3]= { {0, 0,0},
{0, 0,0},
{0, 0,0}};
void clearBoard(void)
{
int r,c;
cout<<endl<<endl;
for(r=0; r<=2; r++)
{
for(c=0; c<=2; c++)
{
tictactoe[r][c]=0;
}
cout<<endl;
}
}
void showBoard (void)
{
int r, c;
cout<<endl<<endl;
for(r=0; r<=2; r++)
{
for(c=0; c<=2; c++)
{
if(tictactoe[r] [c]==0)
cout<<"*";
else if(tictactoe [r] [c]==1)
cout<<"O";
else
cout<<"X";
}
cout<<endl;
}
}
void plotmark( int p)
{
int row, col;
if(p==1)
cout<<"\nPlace 'O' mark in the board (0,0 to 2,2)\n\n";
else
cout<<"\nPlace 'X' mark in the board (0,0 to 2,2)\n\n";
cout<<"Enter row";
cin>> row;
cout<<"Enter column:";
cin>>col;
if(p==1)
tictactoe[row][col]=1;
if(p==2)
tictactoe[row][col]=2;
}
void Play(int player)
{
plotmark(player);
showBoard();
if(player==1)
player=2;
else
player=1;
Play(player);
}
main()
{
showBoard();
Play(1);
return 0;
}
May 7, 2010 at 1:35pm UTC
The first thing I'd do is get rid of the 3x3 2D array and replace it with a one dimensional
array of 9 elements.
May 7, 2010 at 1:39pm UTC
please reply for this because i need it immediately please....
May 7, 2010 at 1:59pm UTC
can you remodel it or can you finish it ? please....