MrEmao @ 2021-06-26 21:02:17
#include<stdio.h>
int main(){
int n,k;
scanf("%d %d",&n,&k);
int sum1=0,count1=0;
int sum2=0,count2=0;
int i;
for(i=1;i<=n;i++){
if(i%k==0){
count2++;
sum2+=i;
}
else{
count1++;
sum1+=i;
}
}
double aver1=(double)(sum1/count1);
double aver2=(double)(sum2/count2);
printf("%.1f %.1f",aver2,aver1);
}
by Plozia @ 2021-06-26 21:16:08
@MrEmao
把下面这两句话:
double aver1=(double)(sum1/count1);
double aver2=(double)(sum2/count2);
改成:
double aver1=(double)sum1/count1;
double aver2=(double)sum2/count2;
by MrEmao @ 2021-06-27 08:27:54
@Plozia 明白了,谢谢