#41837: 數值設定問題而已


yp11351280@yphs.tp.edu.tw (710-43)

學校 : 臺北市私立延平高級中學
編號 : 276272
來源 : [203.72.178.1]
最後登入時間 :
2024-09-12 18:00:55
n698. 超鐽杯的R值 -- wseds | From: [1.164.234.151] | 發表日期 : 2024-08-31 17:37

數值不能依題目設計,會有算不到的地方。例:d<17.43&&d>17.00、d<17.00&&d>16.50,17.00和16.50是算不到了地方(輸入看看你就會懂了)

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    float d;
    cin>>d;
    if(d<17.43&&d>16.99)
        cout<<"1"<<endl;
    else if(d>16.49&&d<17.00)
        cout<<"3"<<endl;
    else if(d>15.99&&d<16.50)
        cout<<"7"<<endl;
    else if(d>15.49&&d<16.00)
        cout<<"10"<<endl;
    else if(d>14.99&&d<15.50)
        cout<<"15"<<endl;
    else if(d<15.00)
        cout<<"20"<<endl;
    else
        cout<<"0"<<endl;
}

 
ZeroJudge Forum