數值不能依題目設計,會有算不到的地方。例: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;
}