90分求助

B2088 计算书费

Star0925 @ 2023-05-31 22:06:00

#include<bits/stdc++.h>
using namespace std;
float book[10]={0,28.9,32.7,45.6,78,35,86.2,27.8,43};
int main()
{
    int n;
    float ans=0;
    book[9]=56;
    book[10]=65;
    for(int i=1;i<=10;i++)
    {
        cin>>n;
        ans+=book[i]*n;
    }
    cout<<ans<<endl;
    return 0;
}

WA原因:Wrong Answer.wrong answer Too short on line 1.


by Star0925 @ 2023-05-31 22:10:57

5测试点

WA了


by Milthm @ 2023-05-31 22:15:45

精确到小数点后一位


by Huangzihan_chicken @ 2023-06-01 16:46:48

#include<bits/stdc++.h>
using namespace std;
float book[10]={0,28.9,32.7,45.6,78,35,86.2,27.8,43};
int main()
{
    int n;
    float ans=0;
    book[9]=56;
    book[10]=65;
    for(int i=1;i<=10;i++)
    {
        cin>>n;
        ans+=book[i]*n;
    }
    cout<<fixed<<setprecision(1)<<ans<<endl;
    return 0;
}

这样就可以了


by Star0925 @ 2023-06-01 19:14:42

@songjiahao_ 感谢


by Star0925 @ 2023-06-01 19:15:36

@Huangzihan_chicken 感谢


|