Lq_1 @ 2022-02-24 14:50:27
#include<stdio.h>
int main(){
int n,k,i;
double sum1,sum2,m1,m2;
scanf("%d %d",&n,&k);
for(i=1;i<=n;i++){
if(n%k==0){
sum1+=i;
m1+=1;
}
else{
sum2+=i;
m2+=1;
}
}
printf("%.1lf %.1lf",sum1/m1,sum2/m2);
return 0;
}
by pengzy___ @ 2022-02-24 14:52:31
@Lq_1 double sum1,sum2,m1,m2;
没有赋值?
by Lq_1 @ 2022-02-24 15:05:15
@pengzy 结果还是不对
by 正负君 @ 2022-02-24 15:07:11
@Lq_1 首先这 double
变量肯定是要赋初值的
by pengzy___ @ 2022-02-24 15:10:47
@Lq_1 赋值为
if(n%k==0)
如果对了求您关注我一下
by Lq_1 @ 2022-02-24 15:20:04
@pengzy 对了,为啥n不行呢
by Lq_1 @ 2022-02-24 15:25:41
@Lq_1 我知道了谢谢,题目没看清