文章
37
粉丝
98
获赞
69
访问
30.2k
所以5000以上包括5000?
#include<iostream>
using namespace std;
void print(float discount, float pay)
{
cout << "discount=" << discount << ",pay=" << pay << endl;
}
int main()
{
float n, discount;
while (cin >> n)
{
if (n < 1000)
{
discount = 1;
}
else if (n < 2000)
{
discount = 0.95;
}
else if (n < 3000)
{
discount = 0.9;
}
else if (n < 5000)
{
discount = 0.85;
}
else
{
discount = 0.8;
}
print(discount, discount * n);
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发