fanshushu @ 2023-03-09 10:04:36
试了很多次2绿3红
#include <bits/stdc++.h>
using namespace std;
int main()
{
float sum1=0.0;
float sum2=0.0;
int i,n,k,num1,num2;
cin >> n >> k;
num1 =0;
num2 =0;
for(i=1; i<=n; i++)
{
if(i%k==0)
{
sum1 = sum1 +i;
num1++;
}
else if(i%k!=0)
{
sum2 = sum2 +i;
num2++;
}
}
printf("%.1f",sum1/num1);
cout << " ";
printf("%.1f",sum2/num2);
return 0;
}
by Composite_Function @ 2023-03-09 10:33:01
开成 double
试一试,怀疑丢精度
by 2021065328ZXY @ 2023-03-18 15:19:47
@fengguangxi 大佬牛