Reputation: 84
I'm trying to get this code to work, however I can't see any problems with it. Scores are inputted for each of the 8 games, and then the winner's name is meant to be imported into a new name array. However, the logic only seems to work on certain data when inputted.
void firstWinner(char firstScore[PLAYERS][SCORE],
char name[PLAYERS][LEN], char quarterName[QUARTERPLAYERS][LEN])
{
int playerOneWinCount = 0;
int playerTwoWinCount = 0;
int i;
int j;
int x = 0;
for(i=0; i < PLAYERS; i+=2, x++)
{
for(j=0; j < SCORE; j++)
{
if(firstScore[i][j] > firstScore[i+1][j])
{
playerOneWinCount++;
}
else if(firstScore[i][j] < firstScore[i+1][j])
{
playerTwoWinCount++;
}
}
if(playerOneWinCount > playerTwoWinCount)
{
strcpy(quarterName[x], name[i]);
}
else if(playerOneWinCount < playerTwoWinCount)
{
strcpy(quarterName[x], name[i+1]);
}
}
}
Upvotes: 0
Views: 71
Reputation: 86
You need to reset the win count values to 0 at the beginning of the players loop.
Upvotes: 2