求助!!!最后三个wa

P5719 【深基4.例3】分类平均

Wmj7700 @ 2022-07-28 16:56:13

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c=1,ma=0,mb=0;
    float suma=0,sumb=0,i,aswa,aswb;
    cin>>a>>b;
    while(c<=a)
    {
        if(c%b==0)
        {
        suma+=c;
        ma++;
        }
        else
        {
        sumb+=c;
        mb++;
        }
        c++;
    }
    aswa=suma/ma;
    aswb=sumb/mb;
    printf("%.1f",aswa);
    cout<<' ';
    printf("%.1f",aswb);
    return 0;
}

by L_zaa_L @ 2022-07-28 16:58:43

@Wmj7700 开double,不要float。


by 野生小卒 @ 2022-07-28 17:00:45

把float换成double试试?


by HeCao2008 @ 2022-07-28 17:02:07

都这年头了还有人用float

开 double 就 ok 了


by Wmj7700 @ 2022-07-28 17:13:30

AC了,感谢各位大佬


|