caibi666 @ 2023-09-16 09:07:22
#include <iostream>
using namespace std;
int main()
{
int n, k;
cin >> n >> k;
int i = 1, he1 = 0, he2 = 0, shu1 = 0, shu2 = 0;
for (i; i < n; i++)
{
if (!(i % k))
{
he1 += i;
shu1 += 1;
}
else
{
he2 += i;
shu2 += 1;
}
}
printf("%.1f,%.1f", he1 * 1.0 / shu1, he2 * 1.0 / shu2);
return 0;
}
by Nobelium_255 @ 2023-09-16 09:16:25
输出,为什么,要有,逗号?
by Nobelium_255 @ 2023-09-16 09:17:32
而且,请,好好,看题目:保留一位小数
by caibi666 @ 2023-09-16 09:25:51
@梦魂初醒 6 ,这里没问题,有问题的是循环i<=n才对。还有就是没有引用cstdio。哥们虽然你很牛逼,但也不能乱说好吧。
by caibi666 @ 2023-09-16 09:27:05
#include <iostream>
using namespace std;
int main()
{
int n, k;
cin >> n >> k;
int i = 1, he1 = 0, he2 = 0, shu1 = 0, shu2 = 0;
for (i; i <= n; i++)
{
if (!(i % k))
{
he1 += i;
shu1 += 1;
}
else
{
he2 += i;
shu2 += 1;
}
}
printf("%.1f,%.1f", he1 * 1.0 / shu1, he2 * 1.0 / shu2);
return 0;
}
改完的代码,测试没问题,提交就报错,还是打错全错。服!
by Nobelium_255 @ 2023-09-16 09:40:13
@caibi666 我都说了你输出为什么要有逗号!
by Nobelium_255 @ 2023-09-16 09:41:34
@caibi666 龙门粗口\
不听别人讲话就不要问问题
by Nobelium_255 @ 2023-09-16 09:46:03
虽然我第二句话确实说错了(
by Nobelium_255 @ 2023-09-16 09:48:42
@梦魂初醒 习惯性认为用的是double了
by caibi666 @ 2023-09-16 12:23:35
@梦魂初醒 哦没看到输出有逗号,眼瞎了,我的,私密马赛