我正在尝试使用此代码,但是我看不出它有任何问题。为8个游戏中的每个游戏输入分数,然后将获胜者的名称导入新的名称数组。但是,逻辑似乎仅在输入时对某些数据起作用。
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]);
}
}
}
答案 0 :(得分:2)
您需要在玩家循环开始时将获胜计数值重置为0.