sduoooh @ 2021-11-11 17:13:40
代码如下,有俩ac...
#include <stdio.h>
int main (){
int n,k,i,ia;
double suma,sumb;
scanf ("%d%d",&n,&k);
for (i=1;i<=n;i++){
if (i%k!=0){
suma+=i;
ia=ia+1;
}
if (i%k==0){
sumb+=i;
}
}
double ava=suma*1.0/ia;
double avb=sumb*1.0/(n-ia);
printf ("%.1lf %.1lf",ava,avb);
return 0;
}
by AlbrecRoon @ 2021-11-11 17:19:03
@sduoooh 这俩换一下就行
if (i%k!=0){
...
if (i%k==0){
by ud2_ @ 2021-11-11 17:19:15
两类数写反了。有几个变量没初始化。
by sduoooh @ 2021-11-11 20:23:35
@ud2_ 解决了,谢谢!
by sduoooh @ 2021-11-11 20:23:51
@AlbrecRoon 解决了,谢谢!