Im working on my tictactoe board using c++ program

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;

}
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#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;

}


Use [code][/ code] tags, it annoys people when you don't.

Also use specific questions.
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.
please reply for this because i need it immediately please....
can you remodel it or can you finish it ? please....
i really need it please
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.

Why do you use array of 9 elements ? Why not 3x3 2D array ?
Topic archived. No new replies allowed.