gpt4 book ai didi

编译器没有看到我的元素被添加到我的数组中

转载 作者:行者123 更新时间:2023-11-30 21:47:56 26 4
gpt4 key购买 nike

这是代码的一部分。我一直尝试编译,但它一直给我这个错误。是不是赋值语句有问题?

ass1cpy.c: In function 'player_data':
ass1cpy.c:26:46: warning: variable 'score' set but not used [-Wunused-but-set-variable]
double average_goals,average_shots,effIndex,score[MAX];

int
player_data(void){
char name[MAX];
int maxgames,playerId,games,minutes,goals,shots,assists,yellowCards,
redCards,checker = 0, i = 0;
double average_goals,average_shots,effIndex,score[MAX];
scanf("%d",&maxgames);
while(scanf("%d %d %d %d %d %d %d %d %s",&playerId,&games,&minutes,&goals,&shots,
&assists,&yellowCards,&redCards,name) == 9){
average_goals = goal_average(goals,games);
average_shots = shots_average(shots,goals);
effIndex = effIndex_cal(goals,assists,redCards,yellowCards,games,maxgames);
if(checker == 0){
printf("Player %d scored %d goals in %d minutes from %d games\nGoals per"
" game: %05.2f\nShots per goal: %05.2f\nEffindex: %05.2f\n",playerId,
goals,minutes,games,average_goals,average_shots,effIndex);
}
checker = 1;
score[i] = effIndex
i++;
}
return 0;
}

如何更改它以便可以编译?

最佳答案

这不是一个错误。这是一个警告。它警告您正在分配一个变量,但从未使用过该变量。它警告您这一点,因为这很可能是一个问题。

关于编译器没有看到我的元素被添加到我的数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32720349/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com