Hdud @ 2022-10-13 08:59:30
这个有什么问题啊,只得了40分
#include<stdio.h>
int main()
{
int k = 0, n = 0, i = 1;
float p = 0, q = 0;
float h = 0, m = 0;
scanf("%d %d", &n, &k);
while (i <= n) {
if (i % k == 0) {
p += i;
q++;
}
else {
h += i;
m++;
}i++;
};
printf("%.1f %.1f", p / q, h / m);
return 0;
}
by 幻想繁星 @ 2022-10-13 09:02:33
@Hdud float精度不够,换成double就好了
by Hdud @ 2022-10-13 09:07:24
@_1412_kid 谢谢大佬
by ybc20250510lbx @ 2022-10-15 10:03:51
你好聪明可爱啊