hey guys i have been having some problems with this tic tac toe program im working on could u guys help me out the problem is taht player x wins randomly
//Programed by viro
//Email:*****
//Release Date:
//Description:
#include <iostream.h>
#include <conio.h>//used for clrscr()
#include <iomanip.h> //used for setw() and other stuff like it
#include <math.h> //used for all upper math functions
#include <ctype.h> //used for conversion or mesurement of an char or string
#include <fstream.h>// used for writing and opening data files
#include <string.h>
#include "matrix.h"
//gobal variables
//
//prototypes
//
main()
{
char board[3][3] ;
int row=0;
int col=0;
int z=0;
int winner=0;
char choice_x;
char choice_o;
clrscr();
board[0][0]=97;
board[0][1]=98;
board[0][2]=99;
board[1][0] =100;
board[1][1]=101;
board[1][2] =102;
board[2][0]=103;
board[2][1]=104 ;
board[2][2]=105;
do
{
cout<< " Welcome To TicTacToe " << endl
<< "please enter the letter that is in the spot you would like to move"
<< " " << " ³" << " " << "³" << " " << endl
<< " "<< board[0][0] <<" " << "³" << " "<< board[0][1] <<" " << "³" << " "<< board[0][2] <<" " << endl
<< " ÄÄÄ" << "Å" << "ÄÄÄ" << "Å" << "ÄÄÄ" << endl
<< " " << "³" << " " << "³" << " " << endl;
cout << " "<< board[1][0] <<" " << "³" << " "<< board[1][1] <<" " << "³" << " "<< board[1][2] <<" " << endl
<< " ÄÄÄ" << "Å" << "ÄÄÄ" << "Å" << "ÄÄÄ" << endl
<< " " << "³" << " " << "³" << " " << endl
<< " "<< board[2][0] <<" " << "³" << " "<< board[2][1] <<" " << "³" << " "<< board[2][2] <<" " << endl
<< "enter letter x : " ;
cin >> choice_x;
switch(choice_x)
{
case 'a':
if (board[0][0]==97)
{
board[0][0]=88;
z++;
}
break;
case 'b':
if (board[0][1]==98)
{
board[0][1]=88;
z++;
}
break;
case 'c':
if (board[0][2]==99)
{
board[0][2]=88;
z++;
}
break;
case 'd':
if (board[1][0]==100)
{
board[1][0]=88;
z++;
}
break;
case 'e':
if (board[1][1]==101)
{
board[1][1]=88;
z++;
}
break;
case 'f':
if (board[1][2]==102)
{
board[1][2]=88;
z++;
}
break;
case 'g':
if (board[2][0]==103)
{
board[2][0]=88;
z++;
}
break;
case 'h':
if (board[2][1]==104)
{
board[2][1]=88;
z++;
}
break;
case 'i':
if (board[2][2]==88)
{
board[2][2]=88;
z++;
}
break;
default:
cout <<"what part of letter do u not understand";
break;
}
cout<< " Welcome To TicTacToe " << endl
<< "please enter the letter that is in the spot you would like to move"
<< " " << " ³" << " " << "³" << " " << endl
<< " "<< board[0][0] <<" " << "³" << " "<< board[0][1] <<" " << "³" << " "<< board[0][2] <<" " << endl
<< " ÄÄÄ" << "Å" << "ÄÄÄ" << "Å" << "ÄÄÄ" << endl
<< " " << "³" << " " << "³" << " " << endl;
cout << " "<< board[1][0] <<" " << "³" << " "<< board[1][1] <<" " << "³" << " "<< board[1][2] <<" " << endl
<< " ÄÄÄ" << "Å" << "ÄÄÄ" << "Å" << "ÄÄÄ" << endl
<< " " << "³" << " " << "³" << " " << endl
<< " "<< board[2][0] <<" " << "³" << " "<< board[2][1] <<" " << "³" << " "<< board[2][2] <<" " << endl
<< "enter letter O : " ;
cin >> choice_o;
switch(choice_o)
{
case ''a':
if (board[0][0]==97)
{
board[0][0]=79;
z++;
}
break;
case ''b':
if (board[0][1]==98)
{
board[0][1]=79;
z++;
}
break;
case 'c':
if (board[0][2]==99)
{
board[0][2]=79;
z++;
}
break;
case 'd':
if (board[1][0]==100)
{
board[1][0]=79;
z++;
}
break;
case ''e':
if (board[1][1]==101)
{
board[1][1]=79;
z++;
}
break;
case 'f':
if (board[1][2]==102)
{
board[1][2]=79;
z++;
}
break;
case 'g':
if (board[2][0]==103)
{
board[2][0]=79;
z++;
}
break;
case 'h':
if (board[2][1]==104)
{
board[2][1]=79;
z++;
}
break;
case 'i':
if (board[2][2]==105)
{
board[2][2]=79;
z++;
}
break;
default:
cout <<endl <<"what part of letter do u not understand";
break;
}
if(z==9)
{cout <<endl<< "OMGS CATS!lawl!noob";}
if(board[0][0]==79&&board[0][1]==79&&board[0][2]||board[0][0]==79&&board[1][0]==79&&board[2][0]==79||board[0][0]==79&&board[1][1]==79&&board[2][2]==79||board[0][1]==79&&board[1][1]==79&&board[2][1]==79||board[0][2]==79&&board[1][1]==79&&board[2][0]==79||board[0][2]==79&&board[1][2]==79&&board[2][2]==79||board[1][0]==79&&board[1][1]==79&&board[1][2]==79||board[2][0]==79&&board[2][1]==79&&board[2][2]==79)
{
cout << " player O wins";
winner++ ;
}
if(board[0][0]==88&&board[0][1]==88&&board[0][2]||board[0][0]==88&&board[1][0]==88&&board[2][0]==88||board[0][0]==88&&board[1][1]==88&&board[2][2]==88||board[0][1]==88&&board[1][1]==88&&board[2][1]==88||board[0][2]==88&&board[1][1]==88&&board[2][0]==88||board[0][2]==88&&board[1][2]==88&&board[2][2]==88||board[1][0]==88&&board[1][1]==88&&board[1][2]==88||board[2][0]==88&&board[2][1]==88&&board[2][2]==88)
{
cout << " player X wins";
winner++ ;
}
}while(z>9||winner==0);
getch();
return 0;
}
// ³=alt179 Å=alt197 Ä=alt196