AnionicCr @ 2024-11-18 20:26:26
为什么还是错啊,改了很多个版本,怎么都不对QAQ
#include<stdio.h>
int main() {
int n=0;
int k=0;
int can=0,cant=0;
float cansum=0;
float cantsum=0;
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++) {
if(i%k==0) {
can++;
cansum=cansum+i;
}
else {
cant++;
cantsum=cantsum+i;
}
}
printf("%.1f",(float)cansum/can);
putchar(' ');
printf("%.1f",(float)cantsum/cant);
return 0;
}
by _buzhidao_ @ 2024-11-18 20:35:09
@AnionicCr
改成 double
,float会爆精。
by _buzhidao_ @ 2024-11-18 20:35:40
@AnionicCr
record
by AnionicCr @ 2024-11-18 20:48:12
@buzhidao这就对了55555555白费心思,谢谢指正5555555