第6行应该为`cin>>n>>k;`
by __yun__ @ 2024-01-25 22:14:46
第12行`if`的条件应该是`i%k!=0`
by __yun__ @ 2024-01-25 22:16:54
第17行应该是`s1=sum1*1.0/j1`,第18行同理
by __yun__ @ 2024-01-25 22:17:39
@[lizhehao](/user/740026)
by __yun__ @ 2024-01-25 22:17:54
改好的代码如下
```cpp
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,j1=0,j2=0;
long long sum1=0,sum2=0;
cin>>n>>k;
for(int i=1;i<=n;i++){
if(i%k==0){
sum1+=i;
j1++;
}
if(i%k!=0){
sum2+=i;
j2++;
}
}
long double s1=sum1*1.0/j1;
long double s2=sum2*1.0/j2;
cout<<setprecision(1)<<fixed<<s1<<" ";
cout<<setprecision(1)<<fixed<<s2;
return 0;
}
```
by __yun__ @ 2024-01-25 22:19:08
感谢大犇!!!
by lizhehao @ 2024-01-27 13:44:54