Hi, im a newbie in programming with only couple of months experience.
This game is a connect 4 game but works basically like a tic tac toe because insted of a piece dropping at the bottom of the board, it would stay in the selected area like tic tac toe
The problems are that when the program asks for the input, it does not show X or O. I think i messed with "turn" and my function for board but i dont know how to fix it. Another thing is that the "Scores" for the players dont show up and I want my board to have labels from 0-4 for row and 0-4 as well as for column but im lost on how to do it xD. I havent wrote the part to see whos the winner yet and if a draw happens
heres the code
#include <iostream>
using namespace std;
#define X -1
#define O 1
void Logo();
void Board1(int board1[5][5]);
int main()
{
int player;
int score1=0;
int score2=0;
int row;
int col;
int board1[5][5]={(0,0,0,0,0),
(0,0,0,0,0),
(0,0,0,0,0),
(0,0,0,0,0),
(0,0,0,0,0),
(0,0,0,0,0)};
Logo();
cout<<"Welcome to dash to four"<<endl;
for (int turn=1; turn <= 25 ; turn++)
{
cout<<score1<<endl;
cout<<score2<<endl;
Board1(board1);
if (turn%2==0)
player=O;
else
player=X;
do
{
cout<<"Player "<<(player==X ? "X" : "O")<<"Please enter a input of Row then Colmn: ";
cin>>row>>col;
}
while(row<0 || row>24 || col<0 || col>24 || board1[row][col] != 0 );
board1[row][col]=player;
}
if (board1[0][0]+board1[0][1]+board1[0][2]+board1[0][3]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[0][1]+board1[0][2]+board1[0][3]+board1[0][4]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[1][0]+board1[1][1]+board1[1][2]+board1[1][3]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[1][1]+board1[1][2]+board1[1][3]+board1[1][4]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[2][0]+board1[2][1]+board1[2][2]+board1[2][3]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[2][1]+board1[2][2]+board1[2][3]+board1[2][4]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[3][0]+board1[3][1]+board1[3][2]+board1[3][3]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[3][1]+board1[3][2]+board1[3][3]+board1[3][4]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[4][0]+board1[4][1]+board1[4][2]+board1[4][3]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[4][1]+board1[4][2]+board1[4][3]+board1[4][4]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[0][0]+board1[1][0]+board1[2][0]+board1[3][0]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[1][0]+board1[2][0]+board1[3][0]+board1[4][0]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[0][1]+board1[1][1]+board1[2][1]+board1[3][1]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[1][1]+board1[2][1]+board1[3][1]+board1[4][1]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[0][2]+board1[1][2]+board1[2][2]+board1[3][2]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[1][2]+board1[2][2]+board1[3][2]+board1[4][2]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[0][3]+board1[1][3]+board1[2][3]+board1[3][3]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[1][3]+board1[2][3]+board1[3][3]+board1[4][3]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[0][4]+board1[1][4]+board1[2][4]+board1[3][4]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[1][4]+board1[2][4]+board1[3][4]+board1[4][4]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[0][0]+board1[1][1]+board1[2][2]+board1[3][3]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[1][1]+board1[2][2]+board1[3][3]+board1[4][4]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[0][1]+board1[1][2]+board1[2][3]+board1[3][4]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[1][0]+board1[2][1]+board1[3][2]+board1[4][3]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[4][0]+board1[3][1]+board1[2][2]+board1[1][3]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[3][1]+board1[2][2]+board1[1][3]+board1[0][4]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[4][1]+board1[3][2]+board1[2][3]+board1[1][4]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[3][0]+board1[2][1]+board1[1][2]+board1[0][3]==-4)
cout<<"Player 1 Sores!";
score1++;
if (board1[0][0]+board1[0][1]+board1[0][2]+board1[0][3]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[0][1]+board1[0][2]+board1[0][3]+board1[0][4]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[1][0]+board1[1][1]+board1[1][2]+board1[1][3]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[1][1]+board1[1][2]+board1[1][3]+board1[1][4]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[2][0]+board1[2][1]+board1[2][2]+board1[2][3]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[2][1]+board1[2][2]+board1[2][3]+board1[2][4]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[3][0]+board1[3][1]+board1[3][2]+board1[3][3]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[3][1]+board1[3][2]+board1[3][3]+board1[3][4]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[4][0]+board1[4][1]+board1[4][2]+board1[4][3]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[4][1]+board1[4][2]+board1[4][3]+board1[4][4]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[0][0]+board1[1][0]+board1[2][0]+board1[3][0]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[1][0]+board1[2][0]+board1[3][0]+board1[4][0]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[0][1]+board1[1][1]+board1[2][1]+board1[3][1]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[1][1]+board1[2][1]+board1[3][1]+board1[4][1]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[0][2]+board1[1][2]+board1[2][2]+board1[3][2]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[1][2]+board1[2][2]+board1[3][2]+board1[4][2]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[0][3]+board1[1][3]+board1[2][3]+board1[3][3]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[1][3]+board1[2][3]+board1[3][3]+board1[4][3]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[0][4]+board1[1][4]+board1[2][4]+board1[3][4]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[1][4]+board1[2][4]+board1[3][4]+board1[4][4]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[0][0]+board1[1][1]+board1[2][2]+board1[3][3]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[1][1]+board1[2][2]+board1[3][3]+board1[4][4]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[0][1]+board1[1][2]+board1[2][3]+board1[3][4]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[1][0]+board1[2][1]+board1[3][2]+board1[4][3]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[4][0]+board1[3][1]+board1[2][2]+board1[1][3]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[3][1]+board1[2][2]+board1[1][3]+board1[0][4]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[4][1]+board1[3][2]+board1[2][3]+board1[1][4]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
if (board1[3][0]+board1[2][1]+board1[1][2]+board1[0][3]==4)
cout<<"Player2 Scores!"<<endl;
score2++;
return 0;
}
void Logo()
{
cout<<" ******************************"<<endl;
cout<<" ************DASH TO*************"<<endl;
cout<<" **********************************"<<endl;
cout<<" *****************4******************"<<endl;
cout<<"*****************4*4******************"<<endl;
cout<<"****************4**4******************"<<endl;
cout<<" **************444444****************"<<endl;
cout<<" *****************4****************"<<endl;
cout<<" ****************4***************"<<endl;
cout<<" ******************************"<<endl;
}
void Board1(int board1[5][5])
{
cout << endl;
for (int row=0; row<5; row++)
{
for (int col=0; col<5; col++)
{
cout << "| ";
if (board1[row][col] == 0) cout << " ";
else if (board1[5][5] == -1) cout << "X";
else if (board1[5][5] == 1) cout << "O";
}
cout << "\n-------------" << endl;
}
}
Really need help on fixing this thing asap