9. 打折

题目:

一件衣服95元,若消费满300元,可打八五折。输入购买衣服件数,输出需要支付的金额(单位:元),保留两位小数。

思路:

直接计算即可。

代码:

#include <iostream>
using namespace std;

int main()
{
const int PRICE = 95;
int total = 0;
double sum = 0.0;
cin >> total;

if (total * PRICE > 300) {
sum = total * PRICE * 0.85;
} else {
sum = total * PRICE;
}

cout << sum << endl;

return 0;
}
原文地址:https://www.cnblogs.com/Hello-Nolan/p/12110202.html