Fix coding

This is assignment congkak(mancala) game.Hope someone can fix and improve this code.

#include<iostream>

using namespace std;

bool checkWinningCondition(int board[], int SIZE)
{
int sum = 0;
for (int i = 0; i < SIZE; i++)
{
if (i == 9 || i == 19)
continue;
sum = sum + board[i];
}
return sum;
}

void display(int board[], int SIZE)
{

for (int i = 19; i >= 10; i--)
{
cout << board[i] << "\t";
}
cout << endl;
cout << "\t";
for (int i = 0; i < 10; i++)
{
cout << board[i] << "\t";
}
cout << endl;
}
void main()
{
int board[20];
for (int i = 0; i < 20; i++)
{
board[i] = 7;
}
board[9] = 0;
board[19] = 0;
display(board, 20);
int player = 1;

int choice = -1;
bool changed = true;
while (checkWinningCondition(board, 20))
{
if (changed == true || choice == 9 || choice == 19)
{
do
{
cout << "Player " << player << " select storehouse:";
cin >> choice;
if (choice > 8 || choice < 0)
cout << "Invalid" << endl;
} while (choice > 8 || choice < 0);
}
if (player == 2)
choice = choice + 10;
int grab = board[choice];
board[choice] = 0;
while (grab > 0)
{
choice = (choice + 1) % 20;
if (player == 1 && choice != 19)
{
grab--;
board[choice]++;
}
if (player == 2 && choice != 9)
{
grab--;
board[choice]++;
}
display(board, 20);
}
if (choice >= 0 && choice <= 9)
{
if (player == 2)
{
changed = true;
cout << "change player" << endl;
}
else
changed = false;
player = 1;
}
else
{
if (player == 1)
{
changed = true;
cout << "change player" << endl;
}
else
changed = false;
player = 2;

}
}
system("pause");



}
Line 5: This is a bool function. Line 14: You're trying to return sum. sum is going to be converted to a bool. Probably not what you want.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
Topic archived. No new replies allowed.