116147zqq @ 2022-11-04 22:35:38
#include <stdio.h>
int main()
{
int n,k,i,a,b,A,B;
float aver1,aver2;
scanf("%d%d",&n,&k);
i=1;
a=0;
b=0;
A=0,B=0;
while(i<=n)
{
if(i%k==0)
{
a=a+i;
A++;
}
else
{
b=b+i;
B++;
}
i++;
}
aver1=a/A;
aver2=b/B;
printf("%.1f %.1f",aver1,aver2);
return 0;
}
by ztj000 @ 2022-11-04 22:45:48
我这里编译是对的
by 116147zqq @ 2022-11-04 22:57:33
@ztj000 可是我这里不对,输入3,答案应该是9,但是输出是10