gpt4 book ai didi

c - 怎么了这让我发疯

转载 作者:太空宇宙 更新时间:2023-11-04 05:58:38 25 4
gpt4 key购买 nike

<分区>

这是我的代码的摘录以及输出。我包含了用于调试目的的打印语句。

我已经打印出代码的 if 语句应该检查的所有值;他们都是正确的。对于添加了 checkWeights 的大多数测试用例(例如,使用 .2、.2、.2、.2),该代码都能正常工作。但是,在 .1、.3、.3、.1 的情况下,代码打印出 Your weight distribution is invalid! 消息,它不应该这样。这里出了什么问题?

代码:

   checkWeights = checkWeights + weights[i];
fprintf(stdout, "%lf\n", checkWeights);
fprintf(stdout, "%lf\n", totalWeight);
fprintf(stdout, "%d\n", i);
fprintf(stdout, "%d\n", categories - 1);

if((i == (categories - 1)) && (checkWeights != totalWeight))
{
fprintf(stdout, "\nYour weight distribution is invalid! Try again.\n");
dataProvided = 0;
break;
}
}

输出:

How many categories are you currently graded on? 4

These 4 categories account for how much of your grade? (1, .85, .1 etc.) .8

Weight for category 1 (1, .3, .22 etc.): .3
Please enter your score in category 1 (1, .23, .32 etc.): .321
0.300000
0.800000
0
3

Weight for category 2 (1, .3, .22 etc.): .1
Please enter your score in category 2 (1, .23, .32 etc.): .323
0.400000
0.800000
1
3

Weight for category 3 (1, .3, .22 etc.): .3
Please enter your score in category 3 (1, .23, .32 etc.): .232
0.700000
0.800000
2
3

Weight for category 4 (1, .3, .22 etc.): .1
Please enter your score in category 4 (1, .23, .32 etc.): .4534
0.800000
0.800000
3
3

Your weight distribution is invalid! Try again.

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