//得到价格 fValue为原价
float GetPrice( float fValue)
{
if( fValue <= 100.0f)
return fValue * 0.95f;
else
{
if( fValue <= 1000)
return fValue * 0.9f;
else
return fValue * 0.85f;
}
}
double k;//原价
double price;//价格
//输入方式可为 std::cin>>k;
if(k<=100) price=k*0.95;
else if(k<1000) price=k*0.9;
else price=k*0.85;
//输出可为 std::cout<
你得先说出完整的需求,然后才能给你解答
你这不写出来了么?