奇怪,为什么对不上测试结果
查看原帖
奇怪,为什么对不上测试结果
1056927
caibi666楼主2023/9/16 09:07
#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;
}
2023/9/16 09:07
加载中...