C++98:90分求助,为什么最后一个测试点不通过?

B2088 计算书费

__Harry_Haiyun__ @ 2023-06-12 21:47:38


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

by yzm0325 @ 2023-06-12 21:52:36

@Harry_Haiyun 是不是因为:

精确到小数点后一位。


|