Serendi_Pity @ 2022-08-28 21:25:13
看不出有问题,样例也是对的,怎么办
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int a,b;
double n,s,c1,d1,c2,d2;
cin>>a>>b;
for(;a>0;a--){
if (a%b==0){
c1+=1;
d1+=a;
}else{
c2+=1;
d2+=a;
}
}
n=d1/c1;
s=d2/c2;
cout<<fixed<<setprecision(1)<<n<<" "<<fixed<<setprecision(1)<<s;
}
by jaco2559 @ 2022-08-28 21:28:04
@sjz520 把变量放在主函数外面
by Serendi_Pity @ 2022-08-28 21:31:39
@jaco2559 已AC 谢谢
by Jerrycyx @ 2022-08-28 21:32:53
@sjz520
by Serendi_Pity @ 2022-08-28 21:33:33
@Jerrycyx 谢谢